- Create a webpage main.aspx
- Drag and drop a?hidden control and <asp:button> control on the web form.
Step 1. main.aspx.vb
Write the following code on page load event
Button1.Attributes.Add("onclick", "getMessage()")
Step 2.In main.aspx
Add the client side-script block
<SCRIPT language=javascript>
function getMessage()
{
var ans;
ans=window.confirm('Is it your confirmation.....?');
//alert (ans);
if (ans==true)
{
//alert('Yes');
document.Form1.hdnbox.value='Yes';
}
else
{
//alert('No');
document.Form1.hdnbox.value='No';}
}
</SCRIPT>
Step 3. main.aspx.vb
To display the value of the value selected by the user in the pop up write the following code
Response.Write(Request.Form("hdnbox"))
2.window.confirm 的默认按钮是"确定" "取消"
怎么能改成别的 比如 "是" "否" ???
改不了的,
不过可以用window.showModalDialog()来做
采用VBscript可以得到相同的效果
<script language="vbscript">
sub hello()
MsgBox"这是一个测试代码。可以根据需要修。",vbDefaultbutton2+vbOkCancel,"代码测试"
end sub
</script>
<body ondblclick="hello()">
博客介绍了创建网页main.aspx的相关操作。在网页表单上拖放隐藏控件和按钮控件,在main.aspx.vb的页面加载事件中添加按钮点击调用函数的代码,在main.aspx添加客户端脚本块,还给出在弹出窗口显示用户所选值的代码。
7万+





