My website hierarchy looks like this-
What I want to do is to call a function which is in Login.master.cs file into Default.aspx.cs.
If the Default.aspx was in the same Login folder the master page would have been called by
var master = Master as Login_Master;
master.myFunction();
but the above code doesn't work if the master page is in another folder.
How could I call the function?
Thank you.
Related
So I have a link in my header placeholder in my MasterPage that takes me to my gallery
<a href="Gallery.aspx" class="logo-text">
Link is:
http://localhost:50803/Gallery.aspx
I created a subfolder called "Order" and used the MasterPage in one of the pages
Then I tried clicking the link in my header and it took me to
http://localhost:50803/Order/Gallery.aspx
Is there any way to change it so it takes me to the intended link?
I have one .aspx page(main) with one .ascx(pageA) on it which have another .ascx(pageB).
On pageA there is a Button function called "SaveButton", from the main page I can execute that function with: pageA.SaveButton(null, EventArgs.Empty);
My problem is: If the button instead is on pageB how do I execute the function then from the main page?
In a web application, I have a default.aspx page and have a button at top and shown below:
When I click the Button-1, a frame is loaded in my page containing two other frames in a frameset. Each frame in frameset loads a htm page.
You can see this as below:
So, hierarchy is as below:
Loaded Default.aspx Page
Click on Button-1
A Frame is loaded in body of default.aspx which hides the previous contents and display newly loaded frame contents.
Newly loaded frame contains a frameset in Default.htm page
Loaded frameset have two frames, first load Header.htm and second loads Contents.htm
What I need to do, I want to set the value of Button-2 in Header.htm and that value is assigned to a javascript variable on Default.aspx load.
I try this var sJSButton2Value = '<%=sButton2Title %>';
sButton2Title comes from server side script depending upon user language.
How, can I pass this to Header.htm from Default.aspx ?
I want to set Button-2 value which is coming from Default.aspx page.
How It can be accomplished ?
You can set the variable in Default.aspx from an iframe like this:
From inside the iframe:
window.parent.SomeFunctionDefinedInDefaultAspx(valueToSet);
This is typically how you would access the "parent" (Default.aspx) of the iframe
f you need the button text to be set in the iframe from Default.aspx, you can do that via querystring in the url your specify for the iframe
I have a template for a website, and I want to edit the aspx files with C#,
thats means that I want each of the aspx files have a code behind file, which is .aspx.cs file for each .aspx exist file.
I opened a new ASP.NET AJAX Website Template and copied the .aspx files, the webconfig and the css to the new website I created.
when I add control and double-click on it in order to create a .aspx.cs file for this page,
it brings me to the source code.
I've added this line as the first line of my aspx file in order to create a .aspx.cs file:
<%# Page Language="C#" AutoEventWireup="true"
CodeFile="Login.aspx.cs" Inherits="Login" %>
but still it dont let me create an aspx.cs file. Does someone know how can I do that?
Right click the folder your ASPX page is in (or the root project if it's in the root folder) and pick "Add New Item..."
Choose "Class", name it Login.aspx.cs, and click "Add"
If you're using a Website Project, it will ask you if you wanted to put the code file in app_code. Answer no.
Change the class declaration to match the Inherits property in your page directive, be a partial, and inherit from WebForms' Page base class:
public partial class Login : System.Web.UI.Page
{
}
I need to have a button on the master page.
Once that button is clicked I generate a string that represents URL.
test.apx is a content page I use and the string will look like something like this:
Example:
www.blah.com/test.aspx?user=blax&develop=extreme_all
Now all I need is to reload the page while content is redirected to the URL I generated.
I hope this makes more sense.
Thanks guys I am new to asp.net and really appreciate any help
Why dont you use Update Panel?
Have the page postback with the updated query string to change what is in your content area
Assuming your masterpage is set up correctly
within the <asp:content> tag of your aspx page that is using the masterpage you created add code to get the query string
Request.QueryString["key"]
example url: http://www.whatever.com?foo=bar&bar=foo
string tmp = Request.QueryString["foo"]
tmp will become "bar"
Now just check the "postback" option of the asp:control you're using to reload the content page or do whatever you to make the page refresh.
If I understand your question correctly, you want to reuse the same code to parse out your user and develop variables from different content pages that use the same master page.
It sounds like you need a strongly typed master page.
First, put your shared code in your master page. Then, expose the parsed data as properties of the master page. Next, simply add the following directive in your content pages:
<%# MasterType VirtualPath="~/mymasterpage.master" %>
Finally, in your content pages, you can reference your properties as such (assuming you created a property called MyUser):
string user = this.Master.MyUser;
You can also use inheritance if you want a different approach. Simply create class that inherits from Page. Then put your shared code in that class. Finally, make your content pages inherit from your new class, instead of Page.