There is a page Login.aspx having a Label control as "Lbl_LoginExpired".
There is also a MasterPage.
I want to change the text of "Lbl_LoginExpired" from within the Master Page.
How can i achieve this?
Note:
1) Login.aspx is NOT a Content page.
2) Label label1=new (Label)Login.FndControl("Lbl_LoginExpired")
is NOT working in MasterPage.
If there is no master page- content relationship between these 2 pages. I think your options are limited. Also i am assuming Lbl_LoginExpired is not a part of an user control that you can register in both pages. I would recommend using Session object to pass this information between these 2 pages.
Hence in your master page
Session["expiredtext"] = "Your login has been expired";
And in your login pag check this session value whether it is null or not and show the content of it.
Lbl_LoginExpired.Text=Session["expiredtext"]?.ToString();
Also do not forget to reset (or abonden session when user logs out)
Related
I have to prevent browser back button.
for example I have two page((using xml & xslt))
Login.aspx
Page1.aspx
1 .while loading Login page I have created one guid and stored in Login.aspx hidden variable
while loading Page1.aspx I have Created another guid and stored in page1.aspx hidden variable
when user clicks browser back button I an sending hidden variable from page1.aspx
to Login.aspx while loading here i need check guids to confirm it is from page1.aspx
and redirect to same page.
// I have to prevent browser back button(any suggestion is appreciated)
This works for me on my asp.net website.
In the login.aspx html, add "onload="window.history.forward();" to the body statement:
<body onload="window.history.forward();">
Note: This only kicks in after the user interacts with Page1.aspx. It will send you user back to Page1.aspx if they use the previous page browser function on Page1.aspx.
I am using a Session["filter"] variable to store the value of a selected dropdown value when a page redirects to itself. But, if any other page is opened then the variable value should be removed. How do I achieve this?
You could use ViewState["filter"] instead which would be specific to that page.
You could say Session["filter"]=string.Emptyon the landing page if the page Redirect page is on the same web site/application.
If it is not then you can clear the session variable using onselectedindexchanged of dropdown event.
In the case of server page inside the application you can also check if page exist like below before clearing a session value
System.Web.Hosting.HostingEnvironment.VirtualPathProvider.FileExists("~/SomePage.aspx");
Basically, I need to validate log-in on a child page which I've successfully done but now I'm required to edit a label on master page to show the Username of the user that successfully log in. This is basically a visual effect problem if you see it just like that but then I'm required to access the master page label from individual child page validate the username there with the table used for log-in and find out the permission status (admin or user), depending on the result activate or deactivate certain command buttons
My child log-in page is named :- Login.aspx
Master page :- Site.master
Master Label:- Label1
Codes I tried to use but they don't quite work
Master.FindControl("Label1").Visible=true;
Label lb=(Label)this.master.FindControl("Label1")
lb.visible=true
lb.text=UserName.text
Please help, I have been breaking my head for day to no avail got some good answers from here the past which I used hope to have the same luck
If you tell your master page to bind the label's value to HttpContext.User.Identity.Name, then you dont have to monkey around with anything in the child page.
In fact, I believe there's a built-in asp.net control for displaying the authentication status of a user.. though I could be wrong.
I wanted to load a .aspx page into contentplaceholder without making a postback. What I have is a master page with 3 contentplaceholders
1.headerContent
2.leftContent
3.mainContent
I have 3 links in the headercontent and according to the selection of those 3 links, i'm showing few menu's on the leftcontent. On selecting any of the loaded menu on the left content i wanted to show/load a .aspx page inside the "maincontent" through the codebehind(C#), without making a refresh or postback. The .aspx pages which i wanted to load aren't inheriting the masterpage.
Other than using Iframes, is there any way to accomplish this??
What I can suggest is to use user controls (.ascx) instead of pages. Have one page that loads all the controls from the start, this page will use the master page and will have its content place holder as the mainContent.
You can have each control inside a div on the page, and set the display of the div to none. Then you can use java script to display just the relevant user control.
I have a master page. In that master page i have a user control which holds a Label control, it shows data read from a text file using marquee.
My text file changes every 2 minutes so I want to reload my user control every 2 minutes without effecting the master page.
How can i do that?
Any help is appreciated.
You could put the user control in an UpdatePanel and refresh the contents via an AsyncPostBack trigger as described in the following article:
http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-updatepanel-triggers
Here is one sluggish solution:
put the label control in a new page (with no master page) and add a timer with that label to refresh every 1 minute or so.
Now, go back to your master page and add an iframe with SRC pointing to the new page you created before. This way, all the refresh effect will be limited to the iframe only and not to your master page.
*Edit: you don't need a timer for the page inside the iframe. Just set the META refresh time period to whatever you want and in the code behind of that page, let the Page_Load event populate the label
UpdatePanel and use a Timer.
http://msdn.microsoft.com/en-us/library/cc295400.aspx