简体   繁体   中英

Unable to find client side html date control from server side

Unable to find client side html date control from server side.

Following html code is for capturing date.

<input type="date" class="form-control" id="dtpdob" runat="server" placeholder="Enter Date of Birth" name="dtpdob"  />

Following code in server side for finding the control of client side.

Dim btns As HtmlInputText = TryCast(Me.FindControl("dtpdob"), HtmlInputText)
If btns.Value = "" Then
   lblErrorText.Text = "No data available"
End If

System is giving the following error in btns.Value

System.NullReferenceException: 'Object reference not set to an instance of an object.' btns was Nothing.

Kindly help.

You can try the following:

Dim btns As HtmlInputControl = DirectCast(Me.FindControl("dtpdob"), System.Web.UI.HtmlControls.HtmlInputControl)
    If btns.Value = "" Then
        lblErrorText.Text = "No data available"
    End If

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM