Reputation:
If I have an html input "<input id="score1" type="text" value=""/>"
and want to initialize it on the c# page load, but I don't want to use asp controls.How do I do it?
Thanks
Upvotes: 1
Views: 560
Reputation: 416049
<input id="score1" type="text" runat="server" value=""/>
Then in your page's load event:
score1.Value = "some value";
Upvotes: 3
Reputation: 83719
You could set a property on the page codebehind, the access the property on the page
public class MyPage
{
public string InputDefaultContent { get; set; }
private void Page_Load(object s, EventArgs e)
{
InputDefaultContent = "Blah";
}
}
then on the page
<input type="text" value="<%= InputDefaultContent %>" />
Upvotes: 2
Reputation: 26169
You can use server-side plain HTML controls, by just using runat="server".
For instance:
<input type="text" runat="server" id="myTextBox" />
// ...and then in the code-behind...
myTextBox.Value = "harbl";
Upvotes: 5