Which values browser collects as a postback data?

前端 未结 3 1288
梦谈多话
梦谈多话 2021-01-25 22:06

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 t

3条回答
  •  温柔的废话
    2021-01-25 22:35

    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.

提交回复
热议问题