Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to set calender extender textbox so that if i chose current date from other textbox calender extender the next calender extender should automatically set to 27 jan 2012.Plz help


Regards Sofia
Posted
Comments
sofia3 27-Sep-12 5:43am    
that is four month plus
wings_ 27-Sep-12 6:29am    
Provide more details about exact what you want this is not a meaningful question..

if you have two calenders then their is no need to change the date of second calender as first because u want in both calender same date then their is no need..because both calender start with same date (current date ) by default
sofia3 27-Sep-12 6:37am    
I dont want same date in both calendar..i juzt want that my second calender would alwaz show 4 month plus date from first calendar...and it depend on the client selection of first calendar date..hope so now its clear plz help
wings_ 27-Sep-12 6:46am    
woh its very simple..i will give you sample code, means you wants..if in first calender i have selected 27-09-2012 then second calender must be start with 27-12-2012

is it.? u have using ajax calender extender..?
sofia3 27-Sep-12 6:55am    
yes..i want 27-01-2013 means four month ..it will show by defauly jan month if user select back date then its ok

you can get some Idea From This code...and change it according to your requirement..to implement this u need a Latest Version 4.0 of Ajax control Toolkit

this is the .aspx page


ASP.NET
<body>
    <form id="form1" runat="server">
    <asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
    </asp:scriptmanager>
    <table>
    <tr>  <td> From Date</td>
    <td> <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>
        <asp:calendarextender id="CalendarExtender1" runat="server" xmlns:asp="#unknown">
            Enabled="True" TargetControlID="TextBox1"  Format="dd/MM/yyyy">
            </asp:calendarextender>
        </td>
    </tr> 
       <tr><td>To Date</td> 
       <td> <asp:textbox id="TextBox2" xmlns:asp="#unknown">
            runat="server"></asp:textbox>
             <asp:calendarextender id="CalendarExtender2" runat="server" xmlns:asp="#unknown">
               Enabled="True" TargetControlID="TextBox2" Format="dd/MM/yyyy"></asp:calendarextender>
          </td>   </tr>     </table>
   
    </form>
</body>


and simply add this code on page load the .cs file is

C#
protected void Page_Load(object sender, EventArgs e)
  {

   CalendarExtender1.StartDate = DateTime.Now;
   CalendarExtender2.StartDate = DateTime.Now.AddMonths(1);

  }


In the above example First calender start with current date and second calender start after one month from current date..

i hope this will give you a some hint

thanks
 
Share this answer
 
Comments
wings_ 27-Sep-12 8:20am    
Please check i have given one solution for you..or just hint.. just do one thing bcoz i have no time.. take a one variable and assign the value of extender1 i.e selected extender1 date + 4 months to that variable.. and assign above varible to extender2.Startdate=Varible_name; ok
Member 11584440 6-Apr-15 11:01am    
Thank you so much for this solution. I had the same question and it was satisfactorily answered!
Amilah
XML
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:CalendarExtender ID="TextBox1_CalendarExtender" runat="server"
    Enabled="True" TargetControlID="TextBox1">
</asp:CalendarExtender>


extBox1.Text = DateTime.Now.ToString("dd-MMM-yyyy");
 
Share this answer
 
v3
Is it fixed that you want to set "27 jan 2012" in second textbox (In all cases).?.
 
Share this answer
 
v2
Comments
sofia3 27-Sep-12 6:28am    
no actually it depends upon start date calendar extender textbox

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