Frage

<input id="inputID" class="textfield" name="myData" maxLength="5" type="text"       autocomplete="off">

I was looking for a way to fill the input box programmatically but there is no value attribute... I tried element.SetAttribute("value", "blahblah"); Any ideas? It involves C# Windows Forms Webbrowser. edit: My thanks go to the only one who responded to my post. I've found a better answer for me which is to set the InnerText and then programmatically click the element so it would behave like if I typed something. I am still wandering though whether I could use SetAttribute or not.

War es hilfreich?

Lösung

If you include the 'runat="server"' attribute in your input tag, then you should be able to access it from the code-behind. For example:

<input id="inputID" class="textfield" name="myData" maxLength="5" type="text" autocomplete="off" runat="server"/>

can be accessed as such:

inputID.Value = "New Text";

Another StackOverflow article explains this: Accessing HTML Elements in ASP.Net.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top