Disable page state in ASP.NET C# [duplicate] - c#

This question already has answers here:
Webforms Refresh problem
(2 answers)
Closed 8 years ago.
I´ve an WebForms application with a simple form which persists values in the DB. The problem is: if I refresh this page (a simple F5), even when the form fields are empty, the last values are persisted again in the DB.
I just want to disable this behavior. How can I do this?
Thanks!

This can be solved with the post-redirect-get pattern. When submitting the form (POST request) the server redirects to a page (e.g. the detail page of the object just modified). This way you "clear" the POST request from the browser history. The user can easily navigate back without having anything saved again. Of course, if he hits the submit button again the form will be stored again.

Related

How to show the same domain name in every page? ASP.NET C# [duplicate]

This question already has answers here:
hide page url asp.net
(6 answers)
Closed 6 years ago.
im a new programmer, and I want to know how can I show the same domain name in every page on my website?
For example: the domain name is www.domain.com and I have a page called Contact.aspx ,So I want to see the domain name only (www.domain.com) in the address bar when I click on "contact" instead of www.domain.com/Contact.aspx
I know that people cant bookmark my site if I do it and I still want to do it.
Thanks for the help!
you could use Server.Transfer instead of Response.Redirect
Using that in every case you will see always the first address that the user have used

How can i have a pages text change based on the button clicked on the previous page in c#? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
So i have a Pricing Table with 3 options, all on Upgrade.aspx.
'Starter'
'Champ'
'Master'
There is a button for each option. They will all navigate to Payment.aspx, but i want some variables, such as cost, and plan name, to be different based on what button they clicked on the previous page.
So if they clicked 'Starter' button, the Payment.aspx page would say Starter. But if they clicked the 'Champ' button, the Payment.aspx page would say Champ.
There are a lot of different ways you could do this. It seems a little ambiguous what would work best for your situation however.
One option is to create a singleton class with a variable which you set via button handles (IE sets the variable to "Starter" if that button was pressed).
Then the view for the Payment.aspx page could pull the information from the singleton class or consume it however you want it to.
You could also use form data, cookies, databases, and a variety of other things. It depends on where you want to store the data and how is easiest for you to store it.
There are a ton of facilities for this kind of event handling. I'd recommend looking at this article and see how it works for you MSDN - Cross-Page Posting in ASP.NET Web forms

Dynamically Add User Controls - And Pass and Take Data from them [duplicate]

This question already has answers here:
Loading user controls dynamically
(3 answers)
Closed 7 years ago.
I need a way to dynamically add user controls to a page, then pass data to those user controls. Then, on a button click, grab all the data from those controls. There will be textboxes, and radio buttons, and dropdownlists and so on in the controls. Can anyone recommend a convenient or efficient way of doing this? Preferably in a way that uses methods built into ASP.net and C#.
Maybe try using a dialog that you can reuse to display or post values
IF your trying to add/view data

Browser back button and state retains? [duplicate]

This question already has answers here:
browser back button is not updating page
(3 answers)
Closed 9 years ago.
I have an eCommerce system where I have listed the Recently Viewed Count and Items as viewer browse its details page.
When the user had viewed any item using any browser and click the Back button of the Browser then, recently viewed items module doesn't get refresh at all. But on reloading the url(Refresh), the module gets refreshed and shows the recently viewed items and Count?
Look to the History.js. This framework uses HTML 5 browser's features and can handle back button events.
Going back does not refresh any data, so you'll need to ask for the information from the server each time you wan't the information updated, for example using Ajax.

How can we make the backward button disable in the all browsers? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Disable browser's back button
Hi everyone,I have a portal site and i want to make the backward button to disable state after the user gets logout.Is it possible by C# programming?Or we need to go for client side scripts like Javascript or jquery?Please help me regarding this .
You can't do anything on the client with server-side code (C#) except send content to the browser.
There are Javascript things you can do to manipulate the history to a degree, but my guess is you have an architecture problem here; There's no reason you should prevent clicking 'back' simply because they have logged out. Your application should detect that they are logged out, and present them with appropriate content.
Finally, to answer your question: You can't just disable the back button. Period.

Categories