newbie: what is postback for??

M

me

Just starting to learn asp.net but i dont understand
what postback is for. I have never in asp.old, php or perl
etc. sent the user back to the same page when a submit button
is clicked. Does asp.net insist on this in order to do
automatic validation of inputfields, or is there some other
explaination?? End result is that I always have to do
Response.Redirect() after a submit, which seems clumsy. I am
doing something wrong??
 
Y

Yuri Belenky

Generaly postback is the process of sending form back to the server, but
actually postback is also the client-side script function which initialize
sending web form to the web server. This function is embedded to the
rendered HTML by ASP.NET Framework.
ASP.NET framework allows developer to determ is the page requested for first
time or this form processing is the result of postback
 
M

Michael Mayer [C# MVP]

My own opinion, but I think it helps keep code more object-oriented to have
a submit button postback to the same page. That way, you don't have two
separate pages that handle the processing associated with a given form.

For example, a login page:
Old way is to have the username & password textboxes on one page, then the
submit button sends to an authorize page that checks to see if it is legal
username/password and does whatever else. In asp.net, all of that is
handled in a single class / web page. It helps with validation, and from a
developer's point of view, it keeps everything associated with login
isolated to the one class/page. And then, you are correct, you would use a
Response.Redirect() to send the user to either an "Access Denied" page or on
to the rest of the site as an authenticated user. That's just one example.

If you change the name of textboxes, or add other fields & controls, you
(generally) only have to worry about changes within the same class - other
web pages won't be affected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top