views:

310

answers:

3

hello,

When page is to be posted back to the server, browser collects the current values of each control and pastes it together into a string. This postback data is then sent back to the server via HTTP POST.

Q1 - Besides control’s Text attributes and SelectedIndexchanged ( thus besides user input data), are there other attributes/values of a control which are saved by a browser as postback data?

Q2 - In case of GridView, which values are saved by a browser on a postback? Only those in a row which the user chooses to edit?

byte

+1  A: 

I'm not asp programmer, so i can't give exact answer, but I'd suggest you to use firefox with addons Live Http Headers, and Firebug (console section).

With this setup you will be able to see exact data sended by browser to your server.

Alekc
+1  A: 

You'd probably want to use a ViewState decoder as well. You can get them in Browser extensions, and use ones off the web. Scott Gu recommends one here: http://weblogs.asp.net/scottgu/archive/2003/02/16/2495.aspx. The ViewState should tell you all you need to know of persisted server properties.

Program.X
+2  A: 

The values of textarea, select, input and button fields are returned in the post. Each value is a key-value pair where the key is the name property of the element.

I think that I have got all the elements that include data in the post:

  • textarea: The value propery is included, i.e. what's typed in the textarea.

  • select: The value property of the selected option is included. If the selected option doesn't have a value property specified, the text of the option is used.

  • input type="text": The value property is included, i.e. what's typed in the input field.

  • input type="password": The value property is included, i.e. what's typed in the input field.

  • input type="submit": If the button was used to send the form, the value property is included, i.e. the text of the button.

  • input type="image": If the button was used to send the form, the coordinates of the mouse click within the image is sent in the post. Names for the x and y coordinates are created by adding ".x" and ".y" to the name of the element.

  • input type="checkbox": If the checkbox is checked, the value property is included. If the element has no value property specified, the value "on" is used.

  • input type="radio": The value property is included from the selected item from each group. (A group is all radio buttons with the same name.)

  • input type="file": The content of the selected file is included, along with the original file path (or only the file name, depending on browser and security settings).

  • input type="hidden": The value property is included.

  • button: If the button was used to send the form, the innerText property is included, i.e. the text of the button with any html markup removed.

A TextBox control is rendered either as an input type="text", an input type="password" or a textarea, depending on the TextMode property. A DropDownList control is rendered as a select element. A Button control is rendered as an input type="submit". A CheckBox control is rendered as an input type="checkbox". And so on... check the rendered html code to see what the actual html elements rendered are.

A GridView only includes any data in the post if it contains any editable form fields, or if it causes a postback (by navigating in the list for example). When doing a postback there is some information stored in a pair of hidden fields, so any control that causes a postback but doesn't send any form data by itself (like a LinkButton for example) does include information about what caused the postback.

Controls may also put data in the ViewState, which is kept in a hidden field in the form. This is also included in the post, but it's just sent to the browser and back again without being changed by the browser.

Guffa