在Calendar控件里绑定的checkbox控件事件怎么不行了
public CheckBox CreateCheckBox()
{
CheckBox chk = new CheckBox();
chk.ID = "newcheckbox";
chk.Checked = true;
chk.BorderColor = System.Drawing.Color.BlueViolet;
chk.AutoPostBack = true;
chk.CheckedChanged += new EventHandler(chk_Changed);
return chk;
} public void chk_Changed(Object sender, EventArgs e)
{
Response.Write("<script language=javascript>alert(\"ffgfg\")</" + "script>");
} protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime myAppointment = new DateTime(2007, 5, 24);
if (e.Day.Date == myAppointment)
{
e.Cell.Controls.RemoveAt(0);
e.Cell.Controls.Add(CreateCheckBox());
}
else
{
e.Day.IsSelectable = false;
}
}
public CheckBox CreateCheckBox()
{
CheckBox chk = new CheckBox();
chk.ID = "newcheckbox";
chk.Checked = true;
chk.BorderColor = System.Drawing.Color.BlueViolet;
chk.AutoPostBack = true;
chk.CheckedChanged += new EventHandler(chk_Changed);
return chk;
} public void chk_Changed(Object sender, EventArgs e)
{
Response.Write("<script language=javascript>alert(\"ffgfg\")</" + "script>");
} protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime myAppointment = new DateTime(2007, 5, 24);
if (e.Day.Date == myAppointment)
{
e.Cell.Controls.RemoveAt(0);
e.Cell.Controls.Add(CreateCheckBox());
}
else
{
e.Day.IsSelectable = false;
}
}
解决方案 »
- windows.open 弹出窗口时不刷新 父页面?求救啊!!!!!!!!!
- 高分请教个问题
- 鼠标经过滚动的星星评分效果
- <%@ Page Language="VB" AutoEventWireup="false" CodeFile="productupdate.aspx.vb" Inherits="admin_productupdata>
- 字符截取(含有0的)
- 一个不是问题的问题,我却不知道怎么解决,谢谢大家帮忙了
- .net 中部署水晶报表的系列问题(思考)
- 为什么MyDataGrid.Columns .Count 的 Count总为零,请帮忙啊 ???
- 强类型和弱类型是什么东东??如何定义的?
- 请教:从微软站点上下载的.NET Framework SDK 是正式版吗,有没有限制?
- 我就不信没人帮忙了
- 有没有研究过chinaren同学录上面的那个地图的兄弟,给点提示我....
if(!isPostback)
<asp:Calendar ID="Calendar1" runat="server" OnDayRender="Calendar1_DayRender"></asp:Calendar>cs:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ } public CheckBox CreateCheckBox()
{
CheckBox chk = new CheckBox();
chk.ID = "newcheckbox";
chk.Checked = true;
chk.BorderColor = System.Drawing.Color.BlueViolet;
chk.AutoPostBack = true;
chk.CheckedChanged += new EventHandler(chk_Changed);
return chk;
} public void chk_Changed(Object sender, EventArgs e)
{
Response.Write("<script language=javascript>alert(\"ffgfg\")</" + "script>");
} protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
DateTime myAppointment = new DateTime(2007, 5, 24);
if (e.Day.Date == myAppointment)
{
e.Cell.Controls.RemoveAt(0);
e.Cell.Controls.Add(CreateCheckBox());
}
else
{
e.Day.IsSelectable = false;
}
}
}
在calendar控件里就不行,在其他控件就行啊,到底什么原因啊
我没有试过
不过在datagrid里面做过类似的做过
如果在后台的话用foreach绑定事件试一试
改为 protected 试一试