davin kurniadi
davin kurniadi

Reputation: 19

input type datepicker with runat="server"

I'm trying to input value datepicker with input type html5 to database SQL Server.

Here the aspx

<input type="text"  id="txtRRDate" name="txtRRDate" />
<script>
     $(function () {
        $("#txtRRDate").datepicker();
     });
</script>'

and when i want to return value from that input type i put runat="server" so i can call it on the logic

    Dim cls As New clsMain
    Dim ds As New DataSet

    Dim strSQL As String = ""
    Dim strWhere As String = ""
    strSQL = "UPDATE TRXHeader"
    strSQL = strSQL & "SET RRReceivedDate = '" + txtRRDate.Value + "'"
    strSQL = strSQL & "WHERE PONo = '" + txtPOno.Text + "'"

But when I run it, the datepicker doesn't show up.

Any suggestions where the problem is?

Thanks in advance, sorry for bad English.

Upvotes: 0

Views: 313

Answers (1)

Stefan Palcu
Stefan Palcu

Reputation: 11

So the problem is that when you put the runat="server" attribute to the input the client id of that input will change. so calling .datepicker() function on the element $("#txtRRDate") will not work as the id txtRRDate doesen't exist in the client document.

You can try what i always do :

`<input type="text"  id="txtRRDate" name="txtRRDate" runat="server" />
<script>
     $(function () {
        $("#<%= txtRRDate.ClientID%>").datepicker();
     });
</script>'`

now the function .datepicker() is called on the client id of the control

Upvotes: 1

Related Questions