Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery POST not changing IsPostback variable

When using jQuery to POST data back to the server, I'm getting some strange behavior.

If I include __VIEWSTATE and __EVENTVALIDATION in my serialized form data, the IsPostback page variable is set to true, If I exclude these two, the IsPostback is set to false.

Its easy enough for me to include these two variables but does anyone know whats going on behind the scenes?

like image 912
Razor Avatar asked Jan 01 '26 06:01

Razor


2 Answers

One of the things the viewstate and eventvalidation track are whether or not a postback has occurred. Considering the event-based ASP.NET page lifecycle, there is no other way to track if a postback has occured than by simply storing the value somewhere.

In other words, you could manually check for postback by digging into the viewstate object and finding the postback boolean and changing it to true. This may not be exactly as described, but it highlights what's going on inside the viewstate a little better.

like image 134
Soviut Avatar answered Jan 03 '26 20:01

Soviut


IsPostBack() is a bit of a mess, but yes it's checking for __VIEWSTATE and __EVENTVALIDATION and not much else. What it certainly doesn't do is check if the HTTP verb is a POST or a GET, which most people assume (you can see this if you set up a simple page and put the viewstate and eventvalidation (if present) fields in the query string then check IsPostBack()

However why would you want to check? Really this only comes into play when a full form submission is sent, if you're partially posting you tend to do it to a web service where IsPostBack is unimportant.

like image 39
blowdart Avatar answered Jan 03 '26 19:01

blowdart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!