post back

RizVience

New Member
So if you can't post to another aspx page if you have runat=server in your form tag (not without using redirect in your button'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're starting with a fresh screen? <BR><BR>It's frustrating that you can'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't like the "post back" method am I just screwed with .Net?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 http://www.15seconds.com/issue/010207.htm for more information about using the panel control.<BR><BR>Re: the reason why you need to do a postback - the Internet, as I'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 http://www.asp101.com/lessons/viewstate.asp 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'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'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'll understand what I'm saying (if you don't already). If you have any specific questions, feel free to ask! :)
 
Back
Top