Here you can find the value from HTML control to code behind using ASP.net
if you still want to get or set values to HTML controls without runat="server" then you can use Request.Form collection to get the value. You can use public property and embedded code blocks to set the value from server. Refer the code below,
ASPX
<input id="txt1" name="txt1" type="text" value="Set in Client Side" />
<input id="txt2" name="txt2" type="text" value="<% =ServerValue %>" />
CodeBehind
public string ServerValue = String.Empty;
protected void btnSave_Click(object sender, EventArgs e)
{
string ClientValue = Request.Form["txt1"];
ServerValue = "Set in Server";
}
}
Please like .....
if you still want to get or set values to HTML controls without runat="server" then you can use Request.Form collection to get the value. You can use public property and embedded code blocks to set the value from server. Refer the code below,
ASPX
<input id="txt1" name="txt1" type="text" value="Set in Client Side" />
<input id="txt2" name="txt2" type="text" value="<% =ServerValue %>" />
CodeBehind
public string ServerValue = String.Empty;
protected void btnSave_Click(object sender, EventArgs e)
{
string ClientValue = Request.Form["txt1"];
ServerValue = "Set in Server";
}
}
0 comments:
Post a Comment