문제

<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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top