我出题时试卷页面使用WEB用户控件testAll分别调用4种题型的试题,用的又是WEB用户控件,分别为test0~test3,其中将RadioButton和的CheckBox的单击事件的结果写到数据库学生答题表中;
    但是调试时test0~到test3的CheckedChanged等事件不响应;
    请问各位高手如何在试卷页面中当学生点击RadioButton或CheckBox时,调用test0~test3中的CheckedChanged等事件并回发点击的数据????
    再线急等,(下周一就要考试了,没法只有求救了!!!!)

解决方案 »

  1.   

    将checkBox或RadioBox的AutoPostBack设置为true
      

  2.   

    试过了,关键是程序运行时不执行子web控件Test0--3?
      

  3.   

    用javascript在body 的onload中写函数调用test0--3.
      

  4.   

    onload中写函数调用test0--3.我现在一团乱麻,没思路啊????
    求救求救!!!!!!!!
      

  5.   

    以前有人也问过类似的问题,他出现这种情况的原因是由于他使用了验证控件,如果本页面输入的不合法(即没有满足验证控件的要求),提交的时候客户端验证不通过,表现为没有任何反应..看看你的页面是否有用过验证控件,假如有,那可能就是这个原因了..Good Luck..
      

  6.   

    没有遇到过,不过用javascript应该可以吧
      

  7.   

    客户端学生试卷中有个交卷Button,可用他来回送学生点击RadioButton或CheckBox的结果,但是我没用过java,如何写一个c#的试卷页面RadioButton或CheckBox的遍历函数且数据要保留,学生点的是什么既答题结果.
    救命!!!救命!!!救命!!!
      

  8.   

    我在试卷页面用((test0)(this.FindControl("test0"))).RB1_CheckedChanged但就是写不对?
      

  9.   

    這樣試看看:
    ((RadioButton)(this.FindControl("test0"))).RB1_CheckedChanged
      

  10.   

    试卷页面的控件关系:web<Panel(n)<testAll(n)<test(n)
    test(n)中有CheckedChanged等事件,目的是结果写到数据库表中;但是测试发现test(n)中的CheckedChanged等从没运行过?????
    加与不加Autopostback均无反应,学生试卷页面没有验证控件
      

  11.   

    studenttest02.aspx.cs(515,4): error CS0117: “System.Web.UI.WebControls.RadioButton”并不包含对“RB1_CheckedChanged”的定义
      

  12.   

    试卷页面生成的代码是:
    <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>&nbsp;&nbsp;

    <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>&nbsp;&nbsp;
    <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>&nbsp;&nbsp;
    <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>
      

  13.   

    如果下列问题解决,上述问题解决,请各位高手帮忙看看!!!!!!!!页面错误提示:
    未将对象引用设置到对象的实例。 
    说明: 执行当前 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>"); }
     
      

  14.   

    试试则个:
    foreach(Control ctrl in Page.Controls)
    {
      if(ctrl.GetType() == RadioButton.GetType())
      {
        //具体实现
      }
      if(ctrl.GetType() == CheckBox.GetType())
      {
        //具体实现
      }
    }
    }
      

  15.   

    我41岁了,头老已经不灵活,谢谢你,showlie(想长膘的小猪……) 的代码出现下列提示,怎么改?
    非静态的字段、方法或属性“object.GetType()”要求对象引用
      

  16.   

    那把RadioButton.GetType()改为Type.GetType(RadioButton)
      

  17.   

    我用 foreach   (   Control   ctrl   in   ((testAll)(this.FindControl("testAll1"))).TableCD.Controls   )   
    {   
    if   (   ctrl.GetType().ToString()   ==   "System.Web.UI.WebControls.RadioButton"   )   
    {   
    allTextBoxValues+=  ((RadioButton)ctrl).Text   ;   
    }   
    }   
    但返回为null,我的Radiobutton在TableCD 内,我已经将Radiobutton改为Public,仍找不到
    谢谢你再帮我想想
      

  18.   

    你设置断点看看,为什么会返回null?是没遍历到还是那个判断没通过。
      

  19.   

    这样试试,应该没有错误啊
    foreach(Control ctrl in this.FindControl("testAll1").TableCD.Controls)   
    {   
      if(ctrl.GetType().ToString() == Type.GetType("System.Web.UI.WebControls.RadioButton"))
     //
    }
      

  20.   

    对了,以上控件是web服务器控件,不是html控件啊!
      

  21.   

    谢谢各位了,我看我得改代码了,试卷页面调用testAll是个web Table然后再调用test 0-n,分别出不同类型的题,除试卷均是web控件,设计界面是找不到的,代码看似少简洁,但其结果回送难办;
    上述办法我试了不行.
      

  22.   

    请问c#如何在调用窗口中找到被调用web控件(.ascx)里的子控件,如ascx中的RadioButton、CheckBox、Label等?
    我的主窗口代码如下:
    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>");
    }
    }
    }
      

  23.   

    调用web控件(.ascx)
    ——————————————————————
    他会生成一个类,LZ调用的时候会生成HTML,但不会生成相应的C#代码。
    要调用子控件,在设计的时候,搞一个公有属性,
    在aspx里用时,通过创建对象可以访问到的。
    若有子控件事件的里代码也执行,好像要用