In this article I will explain with an example, how to bind (assign) value to HTML TextBox from Server Side (Code Behind) in ASP.Net using C# and VB.Net.
There are two ways for setting the values of HTML TextBox from Server Side (Code Behind) in ASP.Net:
1. Using Property.
2. Using runat=“server” attribute.
 
 
HTML Markup
The HTML Markup consists of a Form consisting of two HTML TextBoxes. The Name TextBox has been assigned the Name property value using Server Side Tags while for the Email TextBox, the runat=”server” attribute has been specified.
<form id="form1" runat="server">
    Name:
    <input type="text" id="txtName" name="Name" value="<%=Name %>" />
    <br />
    Email:
    <input type="text" id="txtEmail" name = "Email" runat = "server" />
</form>
 
 
Binding (Assigning) value to HTML TextBox from Server Side (Code Behind) in ASP.Net
Inside the Page Load event, the Name property is set with a value which will later be assigned to the Name TextBox and the Email TextBox is directly accessed and the value is assigned.
C#
protected string Name { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
    this.Name = "Mudassar Khan";
    txtEmail.Value = "test@aspsnippets.com";
}
 
VB.Net
Protected Property Name As String
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    Me.Name = "Mudassar Khan"
    txtEmail.value = "test@aspsnippets.com"
End Sub
 
 
Screenshot
Bind (Assign) value to HTML TextBox from Server Side (Code Behind) in ASP.Net using C# and VB.Net
 
 
Demo
 
 
Downloads