Reputation: 269
I am trying to populate the value of input field with value from property. How can I do that besides setting in the code behind file?
<%@ Import Namespace="PCF.Entities.Models" %>
<input id="firstName" type="text" value="<% %>" size="26" maxlength="15" name="firstName" tabindex="2" runat="server" disabled="disabled" />
Upvotes: 0
Views: 504
Reputation: 348
make your input field runat="server"
and you will get the access of input at code behind file.
Upvotes: 1
Reputation: 62260
You can use <%= %>
<%= Name %>
protected string Name
{
get { return "John Doe"; }
}
However, in your scenario. You should be using ASP.Net Textbox control.
<asp:TextBox runat="server" ID="FirstNameTextBox"
MaxLength="15" Enabled="False" />
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FirstNameTextBox.Text = "John Doe";
}
}
Upvotes: 0