I have a page in asp.net. A button click in the page will open a pop-up.
Now if session is expired, it is opening the pop-up window and in the pop-up it is showing the login screen.
Is there any way in which i can avoid pop-up being opened if the session is expired and directly go back to login page?
When you say pop-up, do you mean window.open? If so, then you have to make a AJAX call to verify the session, before opening the new window.
I am not sure I understand your requirement clearly. There is no exact way to achive this. But we can do it javascript.
put a timer(duration would be session timeout, use settimeout function) in the parent page. Check this value before open a popup.
Related
I would like to disable a submit button on a webform like proposed in:
How to disable postback on an asp Button
But the button should stay disabled, even when the user navigates to some other webpage in the application (like admin page) and then navigates back to the original page; (in my case the button is then not disabled anymore). So is there a way that this button stays disabled (for instance until the user logs off from the application) even in such events and for the whole session until the user logs off?
Thank you for your time and effort.
Add a session variable, example Session("btnDisabled") in the event where you want this to happen and check against it every time a page with the button loads.
If session("btnDisabled")=true then btnSomething.enabled=false
then when the user is logged out, you change that variable, either kill it or set it to false.
I have page that uses a multiview. Each view contains a separate user control. One of these user controls has a list view with an image button that causes the loading of a different view in the multiview. All is fine up until this point. When the user hits the back button, they are taken back to the user control that contains the list view. The user then clicks on another image button to view different data and it returns to the detail user control using the same data as before. While debugging, I have seen that the item command event does not fire after hitting the back button.
I have tried replacing the multiview and putting each user control into separate panels. This did not change the outcome at all.
I have tried setting a cookie that expires 5 seconds after page load. When the user continues to the next page, then clicks back (and it has been longer than 5 seconds), I force the form to submit again. This loads the next control again instead of reloading the page.
I have tried setting the cacheability to no cache. This causes a "page expired" message and the user has to refresh the page. This is ugly for the user and definitely takes away from the user experience.
I am looking for the cleanest way for a user to click back and have the page reloaded so that the item command event fires correctly again.
The reason is that Back doesn't affect the Page Life Cycle. It's definitely because the page is cached and cached page doesn't execute on server. You can try this code to get rid of this issue.
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
It took a lot of research to find this answer, so hopefully other people stumble upon this question and find my answer. I was astonished that I was actually able to find this. Ok, enough gloating.
Because the page does not postback when the user clicks the back button, the events are not fired correctly causing problems with the next page. What has to happen is you need to be able to handle the browser's navigation buttons (i.e. back and forward). To do this you have to set EnableHistory to true within the script manager and handle the Navigate event from the script manager. You can then reload the controls using the information you save in the state object.
I used these articles from Dino Esposito on DotNetSlackers.com as a reference. Server Side History Management and Client Side History Management
I have an asp.net page_load event.
When the user clicks the back button of the browser I want to set some values in the page_load event.
The problem is that when I click on the back botton the page is rendered from Cache and the page load event is not fired.
What should I do so that page_load gets fired ...other than forcing the browsers cache to clear ?
If I understand you correctly you have the following situation:
User visits page A.
User clicks a link and visits page B.
User clicks the back button and page A is displayed again. It is displayed from the browser cache, instead of being refetched from the server.
Is that right? In that case you should mark the page as no-cache. With the Response.CacheControl property you can decide what caching options are returned in the http header of the response.
I came up with a solution.
Indeed the back button has nothing to do with the server events...the page is directly renedered from the browser cache.
So what I did was that I ran a script on the page load but not ASP's page load ,rather the javascript page load.
Whenever the back button is clicked the JS page load would be raised.
How to extend the session time. There are many form in my application like parent and child forms. So how can I make pop up to appear when session times out and the pop up should appear on the form where the user is currently in, when popup comes I have to disable all forms like(they should be transparent (i.e) user should NOT be able to edit them).
how can i extend the session when I click on the OK button. Please can anyone suggest me
You can have a javascript timer running on the page when it loads. When it gets close to the session time out you fire a modal popup with a button to extend the session.
Using a javascript library like JQuery or JQuery UI would make the modal popup real easy to show.
The extender button can be a fake postback that automatically extend the session.
Here are some helpful links:
http://forums.asp.net/t/1136242.aspx
http://forums.asp.net/t/1471076.aspx
http://forums.asp.net/p/1207721/3094847.aspx
Any postback / request to the server will extend your session window.
I have a popup window where i store an a arraylist in sessionvariable, when clicking on closebutton (the X in the right top corner) or the cmd input button in the form i want to remove the sessionvariable containing my arraylist. How can i do this?
The popup window is currently closed by a javascript:
function cmdClose_onclick() {
self.close();
}
Session variables are stored on the server, so you need to inform the server that something happened on the client, and call an appropriate function to remove the session variable.
There are a couple ways you could do this.
You could make an AJAX request to a page, a page method or a custom HTTPHandler. If you write a custom .ashx file, you could simply make a request to it's URL and have it delete the session variable.
Make your page do a postback when you close the window. You can manually trigger postbacks by calling __doPostBack() in javascript, or just executing a button click or form submit.
I'd go with option #1 if you can.
I'd suggest getting the javascript to make an AJAX call to a WebMethod which clears the session variable.