post back

Results 1 to 2 of 2

Thread: post back

  1. #1
    Join Date
    Dec 1969

    Default post back

    So if you can&#039;t post to another aspx page if you have runat=server in your form tag (not without using redirect in your button&#039;s click event anyway) is there a way to clear the page once the form has been submitted so when you come back to it you&#039;re starting with a fresh screen? <BR><BR>It&#039;s frustrating that you can&#039;t use the field validators AND post to a different aspx page with out redirecting and turning all the inputs into querystring values. If I don&#039;t like the "post back" method am I just screwed with .Net?

  2. #2
    Join Date
    Dec 1969

    Default RE: post back

    You can use what are called Panel controls to group together Web controls on your page, and then turn "off" the panel that encompasses your form web controls on postback. (Turning a panel "off" has the effect of hiding the controls in the panel.) See for more information about using the panel control.<BR><BR>Re: the reason why you need to do a postback - the Internet, as I&#039;m sure you know, is stateless. Note that the Web controls in a Web form appear to have state - that is, if you enter "Bob" into a textbox and submit the page, when the page is reloaded, Bob is still in there. Furthermore, you can programmatically access the contents of that textbox (call it txtName) in server-side code using a rich object model (like: txtName.Text). For this to be possible, ASP.NET uses a concept called the Viewstate. (See for more info on Viewstate.) In any case, the Viewstate encodes the "state" of the Web controls when rendered to HTML and sent to the client. The client then enters new values and submits the form back to the Web server. Now, we have the user&#039;s rendition of the state of the controls, so we need to compare it to the Viewstate to see what controls have had values that have changed, what the values of the various controls are, etc. But the only way we can do that is if we know what controls are on the page. If you redirect automatically to a _separate_ page, we don&#039;t know this.<BR><BR>I know the above is probably very confusing, but the argument is sound. If you do some research into the topic, you&#039;ll understand what I&#039;m saying (if you don&#039;t already). If you have any specific questions, feel free to ask! :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts