0

I'm getting really pissed off by this code :D I'm using jQuery datepicker in input field that's set to readonly and the datepicker should appear twice in the same page and it depends on the value of a dropdownlist.

The language i'm using is ASP.NET c#:

the following input textboxes are on my aspx page:

<asp:TextBox ID="txt_check_chequeDate" runat="server" BorderStyle="Solid" 
BorderWidth="2px" Font-Names="Calibri" Style="margin-left: 0px" ClientIDMode="Static" ReadOnly="true"></asp:TextBox>




<tr ID="tr_wire_TransactionDate" runat="server">
    <td>
        <asp:Label ID="lbl_wire_TransactionDate" runat="server" Font-Names="Calibri" 
            Text="Transaction Date"></asp:Label>
    </td>
    <td>
        <asp:TextBox ID="txt_wire_chequeDate" runat="server" BorderStyle="Solid"
            BorderWidth="2px" ClientIDMode="Static" Font-Names="Calibri" 
            Style="margin-left: 0px" ReadOnly="true"></asp:TextBox>
    </td>
</tr>

and my jQuery script is as follows with references:

<script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script>
<script src='../Scripts/jquery-1.4.1-vsdoc.js' type='text/javascript'></script>
<script src='../Scripts/jquery.ui.core.js' type='text/javascript'></script>
<script src='../Scripts/jquery.ui.widget.js' type='text/javascript'></script>



<link href='../Styles/jquery.ui.all.css' rel='stylesheet' type='text/css'/>

<link href='../Styles/jquery.ui.datepicker.css' rel='Stylesheet'
type='text/css' />
<script src='../Scripts/jquery.ui.datepicker.js' type='text/javascript'></script>
<script type='text/javascript'> 
    $(function () {
        $('#txt_check_chequeDate').datepicker({ changeYear: true });

    });
    $(function () {
       $('#txt_wire_chequeDate').datepicker({ changeYear: true });
    });

and when I click the submit button, I get empty value by executing the following:

Debug.WriteLine("on page click value is wire  =  " + this.txt_wire_chequeDate.Text.Trim());
        Debug.WriteLine("on page click value is cheque  =  " + this.txt_check_chequeDate.Text.Trim());

Any idea why I'm getting empty date through datepicker, when i tried eariler i was getting the value correctly for one case only :(

Theg8nj
  • 135
  • 1
  • 16

2 Answers2

3

Remove the readonly attribute on the webform controls and set the readonly attribute through javascript.

<script type='text/javascript'>
        $(function () {
            $("#txt_check_chequeDate").attr("readonly", true);
            $("#txt_wire_chequeDate").attr("readonly", true);
        })
</script>
kblau
  • 2,094
  • 1
  • 8
  • 20
1

As stated in this post try this:

txt_wire_chequeDate.Attributes.Add("readonly", "true"); 
txt_check_chequeDate.Attributes.Add("readonly", "true");

and remove Readonly = "true"

Stefano Losi
  • 719
  • 7
  • 18