Hi,
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
Hi,
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
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";
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 %>" />
<input id="score1" type="text" runat="server" value=""/>
Then in your page's load event:
score1.Value = "some value";