Home > front end >  Unable to find client side html date control from server side
Unable to find client side html date control from server side

Time:01-03

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

Following html code is for capturing date.

<input type="date"  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.

CodePudding user response:

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
  • Related