0

There is an input element in a form whose runat attribute is server. I don't want to define id attibute to it. Following code gives error, because an string has not Value property. How can I do this?

<form id="form1" method="post" enctype="multipart/form-data" runat="server">
    <div id="inpdiv">
          <input type='text' name='inp1' />
    </div>
</form>

In code behind wrong one:

Request.Form["inp1"].Value = "S";

  • Check [Control.ControlCollection.Find](https://stackoverflow.com/a/3898610/5519709) – Selim Yildiz Sep 11 '19 at 18:13
  • @SelimYıldız - that's what i was thinking, but can you actually find a control that does not have `runat="server"`? only the form has it. – wazz Sep 11 '19 at 18:15
  • If you want to find the control from code behind you have to use runat="server" attribute on control. And then you can use Control.FindControl. – Selim Yildiz Sep 11 '19 at 18:33

0 Answers0