-1

I'm trying to use a jscript Datepicker UI calendar when I try to pass the text properties to an sqlparameter in asp.net .cs code. behind I can see the cldStartProj text box object but I can't see the cldEstProjEnd or cldEndProj textboxes.

I am getting an error saying:

"the name 'cldEstEndDate' does not exist in the current context"

How can I get the values from my aspx form from theses datepicker boxes?

<script>
    $(function () {
        $("#cldStartProj").datepicker();
    });
    $(function () {
        $("#cldEndProj").datepicker();
    });
    $(function () {
        $("#cldEstProjEnd").datepicker();
    });
</script>

<p><input type="datetime" id="cldStartProj"></p>
<p><input type="datetime" id="cldEstProjEnd"></p>
<p><input type="datetime" id="cldEndProj"></p>

cmdAdd.Parameters.AddWithValue("@ProjStartDate", cldStartProj.Text);
cmdAdd.Parameters.AddWithValue("@ProjEstEndDate", cldEstProjEnd.Text);
cmdAdd.Parameters.AddWithValue("@ProjEstEndDate", cldEndProj.Text);
War10ck
  • 12,387
  • 7
  • 41
  • 54
Marcus72
  • 99
  • 3
  • 14

2 Answers2

0

You can use asp:TextBox for the datepicker. Then you can access it on the .cs code.

<asp:TextBox CssClass="datePicker" ID="cldStartProj" runat="server" />
<asp:TextBox CssClass="datePicker" ID="cldEstProjEnd" runat="server"  />
<asp:TextBox CssClass="datePicker" ID="cldEndProj" runat="server" />

Then in the script,

$(function () {
    $(".datePicker").datepicker();
});

Use class for binding the datepicker. Id will be change after rendering as it has the attribute runat=server.

Anoop Joshi P
  • 25,373
  • 8
  • 32
  • 53
0

they should asp controls to use in back-end like that

   <p> <asp:TextBox id="cldStartProj"  runat="server" /> </p>
    <p><p> <asp:TextBox id="cldEstProjEnd"  runat="server" /> </p>
    <p><p> <asp:TextBox id="cldEndProj"  runat="server" /> </p>

    cmdAdd.Parameters.AddWithValue("@ProjStartDate", cldStartProj.Text);
    cmdAdd.Parameters.AddWithValue("@ProjEstEndDate", cldEstProjEnd.Text);
    cmdAdd.Parameters.AddWithValue("@ProjEstEndDate", cldEndProj.Text);
Vivekh
  • 4,141
  • 11
  • 57
  • 102