📄 onsubmit.aspx
字号:
<html>
<head>
<title>Submit脚本</title>
<script language="javascript">
function OnSubmit()
{
window.event.returnValue = confirm("您确定要删除选定的项目?");
}
</script>
<script language="C#" runat="server">
void Page_Load()
{
if(!IsPostBack)
{
ArrayList employees = new ArrayList();
employees.Add("Amazon");
employees.Add("Barbarian");
employees.Add("Wizard");
employees.Add("Knight");
employees.Add("Ghost");
CheckBoxList1.DataSource = employees;
CheckBoxList1.DataBind();
Button1.Attributes.Add("onclick", "OnSubmit()");
}
}
void OnDelete(object sender, EventArgs arg)
{
for( int i=0; i<CheckBoxList1.Items.Count; i++)
{
ListItem item = CheckBoxList1.Items[i];
if(item.Selected)
{
CheckBoxList1.Items.Remove(item);
i--;
}
}
}
</script>
</head>
<body>
<h3>Submit脚本</h3>
<form id="form1" runat="server">
<asp:CheckBoxList id="CheckBoxList1" runat="server" />
<hr/>
<asp:Button id="Button1" Text="删除" OnClick="OnDelete" runat="server" />
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -