Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Ev everyone i am using jquery for my 2 textboxes 1.txtStartDate 2.txtEndDate , I have used first date of month as default date for firsttextbox and present date for second text box and on third dropdownList i have used Autopostback as :

<asp:DropDownList ID="ddlWorkType" CssClass="selectbox1 ddlWidth" ValidationGroup="tab1" runat="server" Enabled="true" AutoPostBack="true" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlWorkType_SelectedIndexChanged1">


whenever i select date in first textbox and then select value from dropdownlist it reset the vaue of first textbox again to default

example : textbox1=12-09-2017 textbox2 = 11-10-2017 as i select value in third text box it reset value of textbox1 = 01-10-2017

What I have tried:

$(function () {

           $("#txtStartDate").datepicker({

               dateFormat: 'yy-mm-dd',
               showOn: 'button',
               buttonImageOnly: true,
               buttonImage: '/Image/calender.jpg',
               buttonText: ""
           }).bind("change", function () {
               var minValue = $(this).val();
               minValue = $.datepicker.parseDate("yy-mm-dd", minValue);
           })
           var d = new Date();
           var currMonth = d.getMonth();
           var currYear = d.getFullYear();
           var startDate = new Date(currYear, currMonth, 1);
           $('#txtStartDate').datepicker('setDate', startDate);
           $("#txtEndDate").datepicker({
               dateFormat: 'yy-mm-dd',
               showOn: 'button',
               buttonImageOnly: true,
               buttonImage: '/Image/calender.jpg',
               buttonText: ""
           }).bind("change", function () {
               var minValue = $(this).val();
               minValue = $.datepicker.parseDate("yy-mm-dd", minValue);

           })
           $('#txtEndDate').datepicker('setDate', new Date());
       });
Posted
Updated 11-Oct-17 17:45pm
Comments
Karthik_Mahalingam 11-Oct-17 9:23am    
did you use update panel ?
Member 11644373 11-Oct-17 9:25am    
update pannel on all textbox including dropdown also??
Karthik_Mahalingam 11-Oct-17 23:33pm    
use  Reply  button, to post Comments/query to the user, so that the user gets notified and responds to your text.
Member 11644373 11-Oct-17 9:27am    
I used control pannel als
o

1 solution

refer this

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />

    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script>
        $(function () {
            $("#datepicker").datepicker();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
         
        <p>
            Date:
                <input type="text" id="datepicker">
        </p>
        <asp:DropDownList runat="server" ID="ddl" AutoPostBack="true" OnSelectedIndexChanged="Unnamed1_SelectedIndexChanged">
                    <asp:ListItem Text="text1" />
                    <asp:ListItem Text="text2" />
                </asp:DropDownList> 
        <asp:UpdatePanel runat="server">
            <ContentTemplate>
                
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddl" EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
    </form>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900