making a page as child page of another page - c#

i was finding code for making a page as sub page of some other page which will be known as parent page
like in mvc www.abc.com/home/photos.aspx like photo is a sub page of it . if we write it with home page it opens or something like this can any one help i want to do it in web forms
please give me any idea..........
<input type="button" value="Open a new window"
onclick="OpenWindow()" id="Button1" />
function OpenWindow()
{
window.open("NewWindow.aspx","MyWindow","height=450,width=300");
}
it is not what i am finding like i have two pages i want to open two pages like www.abc.com/firstpage/secondpage.aspx

example.com/home is a folder which contains a so called default page, in ASP.NET that would be Default.aspx. So you could see the same page calling example.com/home/Default.aspx.
example.com/home/photo is yet another folder within the home-folder, containing it's own Default.aspx. You could also call example.com/home/photo/Default.aspx.
What you want are folders and default pages, not "child pages".
Please read this article: ASP.NET Web Project Folder Structure

<form>
<input type="button" value="Open Window"
onClick="window.open('http://www.example.com/firstpage/secondpage.aspx')"/>
</form>
Fiddler
Or
Refer this .Hope it helps you.

Related

Redirect from an asp.net mvc application to a .aspx file?

I have a button in an asp.net MVC 5 web application and I'm trying to redirect the user to an .aspx file.
So that when the user clicks on a button from asp.net MVC (the code of that button is in HTML), he will be redirected to a web form (.apsx).
I tried this code but it doesn't work.
<button id="Login" runat="server" OnClientClick="window.open('Login.aspx', 'Login');">Login </button>
You have to call .aspx page in your Action method.
public ActionResult Login()
{
return Redirect("~/Login.aspx");
}
<a href="#Url.Content("~/Login.aspx")">
<button type="button">Login</button>
</a>
You can embed a button in a hyperlink, so that it appears like a button but works like a link. The trick is getting the URL set correctly. In mixed Web Forms/MVC projects I use the Url.Content helper because it respects the virtual root. You might do well to create a route class however.
public class WebFormsRoutes
{
public const string LoginPage = "~/Login.aspx";
}
With the appropriate namespaces imported, you can then do:
<a href="#Url.Content(WebFormsRoutes.LoginPage)">
<button type="button">Login</button>
</a>
You might also consider looking at the routing documentation. You can register your own Web Forms routes for friendlier URL's
Your code does not look like a Razor View Code.
You can do it multiple ways
1.<button onclick="window.open('Login.aspx')">Login</button>
2. Using Razor
<button onclick="location.href='#Url.Action("Login","Login")'">Login</button>
Thanks
Partha

Observable value from one page to other

Not able to access observable of parent to child page. Scenario listed below...
I have a page listing all the user information (say home page) in a grid and it has action button as well
on click of the action button, i will loading another page (may be user detail page) with the user basic information from the prev (home) page
The code base is something like this
HomePage.cshtml has homepagevm.js
on click of action button, I have function in homepagevm.js and setting the select user info into a observables. I tried with alert statement and I got the values desired
The DetailPage.cshtml has the same homepagevm.js reference. However I am not getting the value (HomePagevm.UserName()).
code base:
In the homepage.cshtml
<a role="button" data-bind="click: $root.isUserdtl">User Detail</a><br>
#Scripts.Render("homepagevm.js")
homepagevm.js has isUserDtl method
homepagevm.isUserdtl= function (element) {
homepagevm.UserName(element.UserName);
}
In the Detailpage.cshtml
<span data-bind="text: homepagevm.UserName()"></span>
#Scripts.Render("homepagevm.js")
I tried accessing by <span data-bind="text: $root.UserName()"></span> and without root syntax also.
I have problem using another VM for the detail page hence clubbed all my method calls in one single js file. Any help would be much appreciated. thank you.

Displaying a content page as popup in asp.net,using

I have a content page(Say.. invoice.aspx) in asp.net application with master pages.
The content page(invoice.aspx) is using a gridview, which displays records from database.
Currently i am navigating to this page using - Response.redirect("invoice.aspx") and this is working fine.
But i need to display this page as pop-up from calling page, so that this popup invoice can be seen on the top of other pages.
Please help me if this can be done using javascript or some other way.
Thanks in advance..
A page popup can be implemented using a div as a container with a different style (opacity, window position, size etc) and has a higher z-index than the rest of the page.
thus basically you need a structure like
<div class="overlayOuter">
<div class="overlayInner">
<!-- external content to be loaded here -->
</div>
</div>
and now using AJAX you load the invoice.aspx page to the inner container and show the container and reduce the opacity of the outer container.
There should be libraries out there that let you do this. you need to explore that on your own.
You can use modal popups for the above scenario:
one example can be found here: http://sandbox.scriptiny.com/tinybox2/
its easy and not much code you need to write and also can load popup as an iframe so postbacks can be handled without posting back parent page or you can use ajax
function OpenWindow(strChildPageUrl) {
var testwindow = window.open(strChildPageUrl, "Child", "width=700px,height=650px,top=0,left=0,scrollbars=1");
testwindow.moveTo(100, 0);
}
</script>

Building multiple form tags on a single asp page

I am trying to be able to put a form tag within another form tag. Here is what the master page is structured as:
<form name="aspnetForm" method="post" action="test.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
-----------CONTENT PLACE HOLDER--------------
</form>
Inside my content place holder i want to put another form:
<form id="test" action="test.ashx" method="post">
</form>
My jquery is trying to .prop this form's (id: #test) action attribute, but it can never find it because the outside form is not letting it. The outside form has a "runat="server"" but the inside one does not. Any ideas of how I can go about doing this?
I suggest you have a look at these to SO Questions and their answers:
Can you nest html forms?
How do you overcome the html form nesting limitation?
In a nutshell you shouldn't be nesting forms.
Are both forms in your DOM? The outer form can't "hide" the inner one from jQuery. $('form#test') should still get it. Just make sure you do not reuse the same id in that page.

How do I merge aspx pages MVC?

I want to merge a sidemenu.aspx on another (Home.aspx, Phone.aspx, Car.aspx... etc) page. How do I do that?
You're a little vague, but I believe you're looking for Master pages, and ContentPlaceHolder controls. The default website when creating a ASP.NET MVC application is set up with some default ones.
In MVC, You can embed a page into another with a function in the "mvc futures" libraries
In your general page you would have:
<% Html.RenderAction("Index", "SideMenu"); %>
Which will call the action "Index" of the controller "SideMenu" that would return the view "sidemenu.aspx"
This could be added to the master page Agent_9191 is talking about!
While you probably should have a Master Page that can contain your sidebar (this is how I do things), you could also have sidebar as a View User Control, which can be rendered using the Html.RenderPartial helper method.
I had to merge webforms pages with an asp.net mvc page a few months ago. The most seamless and easiest way I found to do it was using an iFrame:
<iframe src="/path/to/file.aspx" frameborder="0" width="970" height="970">
</iframe>
It looks like its just part of the site, and the aspx postbacks/viewstate worked perfect with no other changes to asp.net required!

Categories