后台:
protected void Page_Load(object sender, EventArgs e)
{
//Session["RegistrationTitle"].ToString();//标题
//Session["Folder"].ToString();//文件夹名
if (Session["ResultList"]!=null)
{
Session["ResultList"].ToString();//字段信息
}
if (!IsPostBack)
{
//bind control type
this.rbl_Tyle.DataSource = Enum.GetNames(typeof(Common.InfoControlType));
this.rbl_Tyle.DataBind();
this.cbl_Validators.DataSource = Enum.GetNames(typeof(Common.ValidatorType));
this.cbl_Validators.DataBind();
}
//遍历RadioButtonList控件
foreach (ListItem item in rbl_Tyle.Items)
{
item.Attributes.Add("onclick", "validateRadioButtonList(this)");
}
}
前台:
<asp:RadioButtonList ID="rbl_Tyle" runat="server" RepeatDirection="Horizontal"></asp:RadioButtonList>
<asp:Label ID="LabType" runat="server" Text="" ForeColor="Red"></asp:Label>
JS脚本
function validateRadioButtonList(e) {
// var obj = e.value;
alert(e.value);
document.getElementById("<%=LabType.ClientID%>").innerHTML = "";
}