日历控制怀疑 [英] calendar control doubt

查看:118
本文介绍了日历控制怀疑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Page1的场景



- 一个复选框

--fromdate和todate [都是日历控件]



- > fromdate和todate都来自日历控件

- >任务是:fromdate和todate都应该在启动时处于禁用模式。一旦我选中复选框,则应该启用fromdate和todate



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



 <   tr  >  
< td 对齐 = left class = style2 colspan = 4 >
< asp:CheckBox ID = chkroleid runat = server 文本 = 为特定持续时间分配角色

OnCheckedChanged = chkroleid_CheckedChanged / >
< / td >
< / tr >
< tr id = FirstRow runat = 服务器 >
< td class = lavel >
< asp:标签 ID = ll_Appointment_Date runat = server 文字 = 从日期 < span class =code-keyword>> < / asp:Label < span class =code-keyword>>
< / td >
< td 宽度 = 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 文字 = To Date > < / asp:Label >
< / td >
< td width = 25% >
< ; uc3:CalendarControl ID = txt_Appointment_To_Date runat = server ShowTime < span class =code-keyword> =
true
< span class =code-attribute>
SetEnabled = false / >
< / td >
< / tr >





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

SetEnabled =false



现在此功能在日历用户控件中声明如下



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

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









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



如果我运行代码。



fromdate和todate都被禁用



-------------------- --------------复选框部分------------------------------

现在在page1.cs

  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 = ;
txt_Appointment_To_Date.SetEnabled = false ;

}
}





- 现在如果我运行程序..我发现即使我检查或取消选中... fromdate和todate都被禁用....如果我把断点放在chkroleid_CheckedChanged ......调试器不会去那个复选框事件...



- 我在哪里做错了?请帮我解决这个问题。

解决方案

尝试为 AutoPostBack =True >复选框

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--------------------

<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

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

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

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.

解决方案

Try setting AutoPostBack="True" for the CheckBox.


这篇关于日历控制怀疑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆