Click here to Skip to main content
15,904,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Scenario of Page1

--one checkbox
--fromdate and todate [Both are calendar control]

-->both fromdate and todate are coming from calendar control
-->task is : both fromdate and todate should be in disabled mode in start. Once i check the checkbox both fromdate and todate should be enabled

-------------------page1.aspx--------------------

XML
<tr>
                    <td align="left" class="style2" colspan="4">
                        <asp:CheckBox ID="chkroleid" runat="server" Text="Assign Role For Particular Duration"
                            OnCheckedChanged="chkroleid_CheckedChanged" />
                    </td>
                </tr>
                <tr id="FirstRow" runat="server">
                    <td class="lavel">
                        <asp:Label ID="ll_Appointment_Date" runat="server" Text="From Date"></asp:Label>
                    </td>
                    <td width="25%">
                        <uc3:CalendarControl ID="txt_Appointment_From_Date" runat="server" ShowTime="true"
                            SetEnabled="false" />
                    </td>
                    <td class="label" width="10%">
                        <asp:Label ID="Label2" runat="server" Text="To Date"></asp:Label>
                    </td>
                    <td width="25%">
                        <uc3:CalendarControl ID="txt_Appointment_To_Date" runat="server" ShowTime="true"
                            SetEnabled="false" />
                    </td>
                </tr>


-------------------------------------------------------------------------------------
SetEnabled="false"

now this function is declared in calendar user control as below

----------------------------------------------------------------------
C#
public bool SetEnabled
       {
           get
           {
               return this.txtCalendarValue.Enabled;
           }
           set
           {
               this.txtCalendarValue.Enabled = value;
               this.hlnkCalLink.Enabled = value;
           }
       }




-----------------------------------------------------------------------

if i run the code.

both fromdate and todate are disabled

----------------------------------checkbox part------------------------------
now in page1.cs
C#
public void chkroleid_CheckedChanged(object sender, EventArgs e)
    {
        if (chkroleid.Checked)
        {

            txt_Appointment_From_Date.SetEnabled = true;
            txt_Appointment_To_Date.SetEnabled = true;

        }
        else
        {
            txt_Appointment_From_Date.SetEnabled = false;
            txt_Appointment_To_Date.SetEnabled = false;

        }
    }


--now if i run the program.. i find that evenif i check or uncheck ...both fromdate and todate are disabled....and if i put breakpoint in chkroleid_CheckedChanged...the debugger is not going to that checkbox event...

--where i am doing wrong ? Kindly help me resolve this.
Posted

1 solution

Try setting AutoPostBack="True" for the CheckBox.
 
Share this answer
 
Comments
anurag19289 21-Aug-13 11:21am    
just now i saw your answer... i have posted the below answer..and then i saw your answer...

Thanks Tadit.. Yes i am accepting your answer... and i am deleting the below answer...
Thanks a lot Anurag for accepting and up-voting the 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