sas
sas

Reputation: 11

How does browser recognize that an input control is a server control so it should be sent to server?

For example : if i define a plain HMLT control in aspx page and a server control marked as runt="server" then page is submited for postback in the formdata u can see the server controls id with value u have entered.

Upvotes: 1

Views: 109

Answers (2)

ChrisLively
ChrisLively

Reputation: 88044

rsbarro is correct (i upvoted him), however his answer might be a bit confusing.

runat="server" does not affect the browser in any way. It still sees input, selects, and the other standard HTML controls whether they were generated using .Net's controls or by putting the regular html tags in your markup. The browser posts all form data into a "form" collection which is accessible server side using Request.Form["tagname"] or Request["tagname"]

Now in the asp.net, part of the page lifecycle inspects your markup for those runat="server" tags. If it finds them then it will tell the control to load it's values from the Request.Form collection. If an HTML control does not have runat="server", then it is not considered a server control and the only way to access the posted values is through Request.Form["tagname"].

There's more to it, so see rsbarro's link.

Hope this helps.

Upvotes: 1

rsbarro
rsbarro

Reputation: 27339

The browser (client) takes all values in input elements defined with a form tag and sends them to the server when that form is submitted. Adding runat="server" does not affect the client directly (although it may alter the HTML generated by ASP.NET), it allows (among other things) that control to be handled more easily by ASP.NET. For example, when runat="server" is set you can set the control value, make it not visible, etc., from code (either in the page or in the codebehind).

See this MSDN article for more info (specifically the HTML Controls section): http://msdn.microsoft.com/en-us/library/ms973868.aspx

Upvotes: 1

Related Questions