在前台有一组radio(r1,r2,r3)--html控件
在CS文件中怎样设置r1或r2,或r3为选中我想要的效果是,从另外一个页面传过来一个值(‘男/女/不限’)
r1(男),r2(女),r3(不限)
如果传过来的值事‘男’则r1选中,‘女’r2选中(声明radio为html控件,非服务器控件)大家帮下忙

解决方案 »

  1.   

    Response.RegisterClientScript("<script>选中radio的js</script>");
      

  2.   

    我只知道一种方法,加上 runat=server 吧
    还请高人出现
      

  3.   


       radio.checked = true;
      

  4.   


    同意
    给radio一个idrid.checked=true就是选中
      

  5.   

    radio 加runat="server" <input type="radio" id="" runat="server">
    后台直接
    if(传的是"男")
    {
    radio男(ID).Checked=true;
    }
    else if("女")
    {
    radio女(ID).Checked=true;
    }
    else
    {
    radio不限(ID).Checked=true;
    }
      

  6.   

    前台:
     <asp:RadioButtonList ID="RadioButtonList1" runat="server" 
                                            RepeatDirection="Horizontal" Width="156px">
                                            <asp:ListItem Selected="True">型男</asp:ListItem>
                                            <asp:ListItem>索女</asp:ListItem>
                                        </asp:RadioButtonList>
    后台:
    string photo=null;
     if (this.RadioButtonList1.SelectedValue == "型男")
                {
                    photo = "images/GG.gif";
                }
                else
                {
                    photo = "images/MM.gif";
                }
      

  7.   


    <input type="radio" value="男" <%= (Request.QueryString["sex"]=="男")? "checked":""%>/>
    <input type="radio" value="女" <%= (Request.QueryString["sex"]=="女")? "checked":""%>/>
    <input type="radio" value="不限" <%= (Request.QueryString["sex"]=="不限")? "checked":""%>/>
      

  8.   

    加ruant="server"不是我想要的
    我需要的是这种
    Response.RegisterClientScript(" <script>选中radio的js </script>"); 
      

  9.   

    给所有的radio加上 name="radSex"然后在html页面加上如下js代码   <script type="text/javascript">
            function CheckedRad(radId,strSex)
            {
                if(parseInt(radId) > 0)
                {
                    var rad = document.getElementsByName("radSex");
                    if(rad != null)
                    {
                        for(var i = 0; i < rad.length ; i++)
                        {
                            if(rad[i].value == strSex)
                            {
                                rad[i].checked = true;
                            }
                        }
                    }
                }
            }
        </script>
    然后 Response.RegisterClientScript(" <script> CheckedRad(1,男)</script>"); 
    Response.RegisterClientScript(" <script> CheckedRad(1,男)</script>"); 
    Response.RegisterClientScript(" <script> CheckedRad(1,男)</script>"); 
    这两个参数你自己看着处理