Dear Pros,
I have created a control page(.ascx) which has a drop down list box, two text boxes with a search button. The two text boxes are readonly which should be enter the date by a pop-up calendar.
User should select from the drop down list and the text boxes(date range) and click the search button. The grid view will refresh by the selected data.
(That's why I need to set the text boxes to be readonly in order to ensure the format of the date, to avoid the overflow error of the query)
After I enter the date range , choose the drop down list and click the search button, the date range text boxes are all reset to nothing while the drop down list still keep my selection. (My grid view is refresh without data too)
I think that is the problem of page_load that it create the text boxes again? but why the drop down list will not happen the same problem?
following is the code:
HTML:
Sub Page_Load(Sender As Object, E as EventArgs)
hlStartDate.NavigateUrl = "Javascript
ickDate('" & txtStartDate.ClientID & "')"
hlEndDate.NavigateUrl = "Javascript
ickDate('" & txtEndDate.ClientID & "')"
End Sub
Code:
<table>
<tbody>
<tr><td>
<asp:Label id="lblDate" runat="server" forecolor="Black" text="Date">Date:</asp:Label>
</td>
<td>
<asp:HyperLink id="hlStartDate" runat="server" ImageUrl="Images\date-picker.gif"></asp:HyperLink>
<asp:TextBox id="txtStartDate" runat="server" readonly="true" AutoPostBack="false"></asp:TextBox>
</td>
<td>
<asp:Label id="lblTo" runat="server" forecolor="Black" text="To">To</asp:Label>
</td>
<td>
<asp:HyperLink id="hlEndDate" tabIndex="1" runat="server" ImageUrl="Images\date-picker.gif"></asp:HyperLink>
<asp:TextBox id="txtEndDate" runat="server" readonly="true" AutoPostBack="false"></asp:TextBox>
<asp:button id="cmdSearch" tabIndex="3" runat="server" Text="Search"></asp:button>
<asp:Label id="label1" runat="server" forecolor="Black" text="label1">To</asp:Label> </td></tr> <tr><td>
<asp:Label id="lblUserID" runat="server" forecolor="Black" text="User ID">User ID:</asp:Label>
</td>
<td colspan="3">
<asp:SqlDataSource id="UserDataSource" SelectCommand="SELECT * FROM tbl_user Order By user_ID" ConnectionString="<%$ ConnectionStrings:server1 %>" ProviderName="System.Data.SqlClient" Runat="server"></asp:SqlDataSource>
<asp
ropDownList id="UserList" tabIndex="2" runat="server" AutoPostBack="False" DataValueField="User_ID" DataTextField="User_Name" DataSourceID="UserDataSource"></asp
ropDownList>
</td></tr>
</tbody>
</table>
I have created a control page(.ascx) which has a drop down list box, two text boxes with a search button. The two text boxes are readonly which should be enter the date by a pop-up calendar.
User should select from the drop down list and the text boxes(date range) and click the search button. The grid view will refresh by the selected data.
(That's why I need to set the text boxes to be readonly in order to ensure the format of the date, to avoid the overflow error of the query)
After I enter the date range , choose the drop down list and click the search button, the date range text boxes are all reset to nothing while the drop down list still keep my selection. (My grid view is refresh without data too)
I think that is the problem of page_load that it create the text boxes again? but why the drop down list will not happen the same problem?
following is the code:
HTML:
Sub Page_Load(Sender As Object, E as EventArgs)
hlStartDate.NavigateUrl = "Javascript

hlEndDate.NavigateUrl = "Javascript

End Sub
Code:
<table>
<tbody>
<tr><td>
<asp:Label id="lblDate" runat="server" forecolor="Black" text="Date">Date:</asp:Label>
</td>
<td>
<asp:HyperLink id="hlStartDate" runat="server" ImageUrl="Images\date-picker.gif"></asp:HyperLink>
<asp:TextBox id="txtStartDate" runat="server" readonly="true" AutoPostBack="false"></asp:TextBox>
</td>
<td>
<asp:Label id="lblTo" runat="server" forecolor="Black" text="To">To</asp:Label>
</td>
<td>
<asp:HyperLink id="hlEndDate" tabIndex="1" runat="server" ImageUrl="Images\date-picker.gif"></asp:HyperLink>
<asp:TextBox id="txtEndDate" runat="server" readonly="true" AutoPostBack="false"></asp:TextBox>
<asp:button id="cmdSearch" tabIndex="3" runat="server" Text="Search"></asp:button>
<asp:Label id="label1" runat="server" forecolor="Black" text="label1">To</asp:Label> </td></tr> <tr><td>
<asp:Label id="lblUserID" runat="server" forecolor="Black" text="User ID">User ID:</asp:Label>
</td>
<td colspan="3">
<asp:SqlDataSource id="UserDataSource" SelectCommand="SELECT * FROM tbl_user Order By user_ID" ConnectionString="<%$ ConnectionStrings:server1 %>" ProviderName="System.Data.SqlClient" Runat="server"></asp:SqlDataSource>
<asp


</td></tr>
</tbody>
</table>