Introduction:
Note: To get the values on server side code of HTML control, we need to follow below points:
- The tag should have an attribute called NAME. Because it is used as key in form[].
- The form method should be of type POST.
I hope this will be helpful for you.
Sometimes we need to create html controls dynamically on page and whenever some events raised like button or image button click event on server side code and we need to retrieve the values of those html controls as it is not declared as runat="server" on the page.
Here is the simple way to get values of the html input controls which doesn't have runat="server" attribute defined.
Source Code:
<input type="text" name="_name" />
<asp:Button ID="btnShow"
runat="server"
Text="Show"
onclick="btnShow_Click"
/>
protected void btnShow_Click(object
sender, EventArgs e)
{
string
strValue = Page.Request.Form["_name"].ToString();
Response.Write(strValue);
}
Note: To get the values on server side code of HTML control, we need to follow below points:
- The tag should have an attribute called NAME. Because it is used as key in form[].
- The form method should be of type POST.
I hope this will be helpful for you.

nice article
ReplyDeletethanks!
ReplyDelete