RadioButtonList的选择确认

RadioButtonList的选择确认~!

不说废话,看代码~!

 

        protected void Page_Load(object sender, EventArgs e)
        {
            
this.RadioButtonList1.Items[1].Attributes.Add("onclick""if(!confirm('您真的要点我吗?')){document.getElementById('" + this.RadioButtonList1.ClientID+ "_0').checked=true;event.returnValue=false;}");

        }

 

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">
    
<title>无标题页</title>

</head>

<body>
    
<form id="form1" runat="server">
    
<div>
        
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
            
<asp:ListItem Selected="True">1</asp:ListItem>
            
<asp:ListItem>2</asp:ListItem>
        
</asp:RadioButtonList>
    
</div>
    
</form>
</body>
</html>
posted @ 2008-11-28 17:00  景天  阅读(386)  评论(0编辑  收藏  举报