Search code examples
c#htmlcontrols

Get value of input type number in c#


example:

<input id="txtEntQty" type="number" min="1" max='<%# Eval("RemQty")%>' value='<%# Eval("RemQty")%>'>

code behind:

int ASSIGNQTY = Convert.ToInt32((row.Cells[12].FindControl("txtQty") as **?????**).value);

Solution

  • Try this make your input runat="server"

    <input type="number" id="txNUm" runat="server" />
    

    And in .cs code where you want to get value write thiss

    System.Web.UI.HtmlControls.HtmlInputControl input = (System.Web.UI.HtmlControls.HtmlInputControl)gvrow.Cells[5].FindControl("txNUm");
    int ASSIGNQTY = Convert.ToInt32(input.Value);