我出题时试卷页面使用WEB用户控件testAll分别调用4种题型的试题,用的又是WEB用户控件,分别为test0~test3,其中将RadioButton和的CheckBox的单击事件的结果写到数据库学生答题表中;
但是调试时test0~到test3的CheckedChanged等事件不响应;
请问各位高手如何在试卷页面中当学生点击RadioButton或CheckBox时,调用test0~test3中的CheckedChanged等事件并回发点击的数据????
再线急等,(下周一就要考试了,没法只有求救了!!!!)
但是调试时test0~到test3的CheckedChanged等事件不响应;
请问各位高手如何在试卷页面中当学生点击RadioButton或CheckBox时,调用test0~test3中的CheckedChanged等事件并回发点击的数据????
再线急等,(下周一就要考试了,没法只有求救了!!!!)
解决方案 »
- win XP环境下如何防止SQL Server 2000数据库的DateTime型字段自动加入AM/PM?
- progressBar控件的使用
- C#继承问题
- 受不了这C#中的oledb连接方式了
- 使文本框获得焦点时触发一个事件
- 我在codeproject中看到一段代码关于使用RAS拨VPN的,但需要先将VPN设置好,并保存密码才能拨号,有哪位大虾能帮我改改这段代码
- 十万火急:用户控件中javascript调用客户端Object组件问题,高手请进~!!!
- C#运行过程卡住怎么解决?
- sqlDataAdapter.Update的问题,着急啊
- 关闭加载dll的程序,任务管理器依然存在!
- 读取文件,将内容转成二进制字符串。
- datagird中嵌套dropdownlist,dropdownlist的当前值为选定值
求救求救!!!!!!!!
救命!!!救命!!!救命!!!
((RadioButton)(this.FindControl("test0"))).RB1_CheckedChanged
test(n)中有CheckedChanged等事件,目的是结果写到数据库表中;但是测试发现test(n)中的CheckedChanged等从没运行过?????
加与不加Autopostback均无反应,学生试卷页面没有验证控件
<TD colspan="2" vAlign="middle" align="right" style="FONT-SIZE: 14px; COLOR: #0000cc; HEIGHT: 35px">
点选答案:
<span style="color:#0000C0;font-size:16px;"><input id="TestAll1__ctl3_RB1" type="radio" name="TestAll1:_ctl3:dar" value="RB1" onclick="RB1_CheckedChanged" />
<label for="TestAll1__ctl3_RB1">A</label></span>
<span style="color:#0000C0;font-size:16px;"><input id="TestAll1__ctl3_RB2" type="radio" name="TestAll1:_ctl3:dar" value="RB2" onclick="RB1_CheckedChanged" /><label for="TestAll1__ctl3_RB2">B</label></span>
<span style="color:#0000C0;font-size:16px;"><input id="TestAll1__ctl3_RB3" type="radio" name="TestAll1:_ctl3:dar" value="RB3" onclick="RB1_CheckedChanged" /><label for="TestAll1__ctl3_RB3">C</label></span>
<span style="color:#0000C0;font-size:16px;"><input id="TestAll1__ctl3_RB4" type="radio" name="TestAll1:_ctl3:dar" value="RB4" onclick="RB1_CheckedChanged" /><label for="TestAll1__ctl3_RB4">D</label></span>
</TD>
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误: 行 513:
行 514:
行 515: if (((RadioButton)(this.FindControl("TestAll1__ctl5_RB1"))).Checked )
行 516: {
行 517: Response.Write("<script language='JavaScript'>window.alert('TestAll1__ctl5_RB1');</script>"); }
foreach(Control ctrl in Page.Controls)
{
if(ctrl.GetType() == RadioButton.GetType())
{
//具体实现
}
if(ctrl.GetType() == CheckBox.GetType())
{
//具体实现
}
}
}
非静态的字段、方法或属性“object.GetType()”要求对象引用
{
if ( ctrl.GetType().ToString() == "System.Web.UI.WebControls.RadioButton" )
{
allTextBoxValues+= ((RadioButton)ctrl).Text ;
}
}
但返回为null,我的Radiobutton在TableCD 内,我已经将Radiobutton改为Public,仍找不到
谢谢你再帮我想想
foreach(Control ctrl in this.FindControl("testAll1").TableCD.Controls)
{
if(ctrl.GetType().ToString() == Type.GetType("System.Web.UI.WebControls.RadioButton"))
//
}
上述办法我试了不行.
我的主窗口代码如下:
switch (tlx.ToString())
{
case "单选":
this.Ltnum0.Text="共 "+i.ToString()+" 小题:"; test0 ufl0=(test0)this.LoadControl("test0.ascx");
ufl0.Id=sdr.GetString(0);
ufl0.Xh=this.xh.ToString();
ufl0.Jsq=i; Panel1.Controls.Add( ufl0 ); break; case "多选": this.Ltnum1.Text="共 "+i.ToString()+" 小题:"; test1 ufl1=(test1)this.LoadControl("test1.ascx");
ufl1.Id=sdr.GetString(0);
ufl1.Xh=this.xh.ToString();
ufl1.Jsq=i; Panel2.Controls.Add( ufl1 ); break;
}
我在主窗口下为何找不到test0.ascx中定义的RadioButton、CheckBox、Label等?我的代码如下:
foreach(Control ctrl in Panel1.Controls )
{
allTextBoxValues+=ctrl.ClientID.ToString()+ctrl.GetType().ToString()+"===";
if(ctrl.GetType()==Type.GetType("Table"))
foreach(Control ctrl0 in ctrl.Controls)
{
if(ctrl0.GetType() == Type.GetType("RadioButton"))
{
//具体实现
Response.Write("<script language='JavaScript'>window.alert('"+ctrl0.GetType().FullName.ToString()+"');</script>");
}
if(ctrl0.GetType() == Type.GetType("CheckBox"))
{
//具体实现
Response.Write("<script language='JavaScript'>window.alert('"+ctrl0.GetType().FullName.ToString()+"');</script>");
}
}
}
——————————————————————
他会生成一个类,LZ调用的时候会生成HTML,但不会生成相应的C#代码。
要调用子控件,在设计的时候,搞一个公有属性,
在aspx里用时,通过创建对象可以访问到的。
若有子控件事件的里代码也执行,好像要用