Solved

What's in a postback request?

Posted on 2006-06-30
6
1,538 Views
Last Modified: 2012-06-21
I'm looking for links that describe the content of a "postback" request from the client to the server.  I'd like to understand how different types of controls, including hidden fields, send their information back to the server, and how the server recognizes that this is postback that contains such data, and so on.

Any guidance on this would be appreciated.

Thanks!
0
Comment
Question by:codequest
  • 3
  • 2
6 Comments
 
LVL 12

Assisted Solution

by:deanvanrooyen
deanvanrooyen earned 200 total points
ID: 17020254
"...To use automatic postback, you simply need to set the AutoPostBack property of a web control to
true (the default is false, which ensures optimum performance if you don’t need to react to a change
event). When you do, ASP.NET uses the client-side abilities of JavaScript to bridge the gap between
client-side and server-side code.
Here’s how it works: if you create a web page that includes one or more web controls that are
configured to use AutoPostBack, ASP.NET adds a JavaScript function to the rendered HTML page
named __doPostBack(). When called, it triggers a postback, posting the page back to the web server
with all the form information.
ASP.NET also adds two hidden input fields that the __doPostBack() function uses to pass information
back to the server. This information consists of the ID of the control that raised the event
and any additional information that might be relevant. These fields are initially empty, as shown
here:
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
The __doPostBack() function has the responsibility for setting these values with the appropriate
information about the event and then submitting the form. A sample __doPostBack() function is
shown here:
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform = document.Form1;
theform.__EVENTTARGET.value = eventTarget;
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
Remember, ASP.NET generates the __doPostBack() function automatically. This code grows
lengthier as you add more AutoPostBack controls to your page, because the event data must be set
for each control.
Finally, any control that has its AutoPostBack property set to true is connected to the
__doPostBack() function using the onClick or onChange attribute. These attributes indicate
what action the browser should take in response to the client-side JavaScript events onClick
and onChange... "

buy pro asp.net 2.0 C# - I dont know if there is a vb version, it a good buy, I got it cheap $25 make sure you get the 2.0
0
 
LVL 2

Author Comment

by:codequest
ID: 17020395
Thanks for the input.   That's very useful in terms of how the postback process works.  Actually, though, I think I really need to see the actual format/structure/content/whatever of the Request transmission string before I'm going to "get it".   I see from your post how ASP.NET uses javasrcript to add stuff to that string...I still don't have a picture of what the resulting request string is going to look like, how it will be structured, what all's in it and so on.  That's what's going to put it together for me.
0
 
LVL 5

Assisted Solution

by:CyberneticsConnoisseur
CyberneticsConnoisseur earned 300 total points
ID: 17020462
Hi

Information is passed through ViewState in Postback in .NET
Viewstate is a collection of name/value pairs, where control's and page itself store information that is persistent among web requests.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.asp


http://delphi.about.com/library/weekly/aa051705a.htm

These 2 links have the ans to your question and give more details about the same

Carpe Diem
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
LVL 2

Author Comment

by:codequest
ID: 17020718
Thanks for the links.   They are great.  Best clear explanation of page cycle I've seen (it's got PICTURES!);  and the stuff on viewstate is something I've needed to wrap my head around for a while.  Actually, I want to take them both home and introduce them to my mother!  But I'm not sure how to explain why I'm seeing two such attractive URL's at the same time... :-)

Sadly, though, I'm still not seeing what the request string looks like.  This comes close:  but it's one of those "object" things, and I'm such a "string" guy...I'm not sure how to raise the kids or anything...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/54d9972a-b6cd-4672-b62a-8793ce8ad335.asp

Perhaps the response string is shy, and does not like to be seen "unencapsulated"...sigh...

Well, so, see, at least my questions are becoming more intelligent  (?)  All good news!  <:*)

0
 
LVL 5

Accepted Solution

by:
CyberneticsConnoisseur earned 300 total points
ID: 17020862
Hi,

As regards your question about how different types of controls send their information back to the server, as mentioned earlier, they are sent through Viewstate which is a serialized base-64 encoded string collection of name/value pairs.

The link also briefs on how you may decode the ViewState

As regards your question about how the server recognizes that this is postback, the isPostBack Property of the page also derives this from the viewstate itself.

As regards the Request Object whose corresponding string representation you
wish to see, an object contains a lot of other details that cant be directly converted to and displayed as a string, but as you may already be knowing ASP.NET provides the functionality to view their values individually.

To that effect I believe, you may not be able to view the corresponding representation and I guess that makes sense too.

Hope this helps

0
 
LVL 2

Author Comment

by:codequest
ID: 17020903
Yes, that helps.   Particularly with respect to the postback.  That kind of like popped something.

I'm getting that a simple request string might look like this:

http://localhost/script/directory/NAMES.ASP?Q=Fred&Q=Sally 

but that a complex request string with serialized vewstate control values could look like anything.  

In particular I was having trouble with a picture that got stuck in my head early in my attempt to understand this material that somehow the entire page (all the html) was involved in the request...which I KNEW couldn't make any sense, because of the transmission cost.   Now that's gone (whew!) and with the seventh re-read of the page cycle (the picture do help) I'm beginning to see how this actually might all work on a real physical computer.

Price of going into consulting in the 90's...

Thanks for the help!



0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax Error 2 66
ASP.NET 5 Templates 2 78
ASP.net Run 3 sliders vertically as opposed to horizontally 9 21
ASP.net 2015 Syncing Azure web app projects on two machines 2 21
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question