asp disable button for the whole session - asp.net

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.

Related

Load data from cookie event

Please give peace of advice. I have login form. Login and password textboxes, and button 'enter'. Button disabled if textboxes are empty. So I've made client side event that makes button enable. Event TextChaged for both textboxes. But after entering to application users login and password wrote to cookies. When I entering the next time, I past the login name into the first box, password appears automatically. And 'enter' button still disabled. Does exist some event that occurs after cookies was paste?
ps: used devexpress textboxes
When you enter Login details second time, your textchange event should ideally have fired! and 'Enter' button should have been enabled. Are you sure its all working fine?
Alternatively, here is what you can do:
onblur event of the textbox, check the length of both the text boxes (Login & Password). If length is greater than zero for both textboxes, enable the Enter Button.
Hope it helps.

Browser back button does not move to the previous View

I am using views concept in my asp.net form control.my first view consist of a form to capture user details.when user press continue it will move to the second view.
The problem is ,When user press the back button of the browser from the second view it doesn't move the the previous view instead move to the previous page in the browser history.
I wanted to move to the first view with the existing data in the form,when user press the back button of the browser.
You should perform a full page postback I guess, so that at client end your previous view will be saved in browser's history.

listview itemcommand not firing after back button

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

ASP.NET Event rasied on back button of browser

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 Can I extend The session time when there are multiple forms

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.

Resources