The sample code?is on the most frequently asked query on “How to get the confirmation of Yes/No from a javascript pop up and display the value on the page using ASP.NET”?
- 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”))
这是通过表单获取,如果没有表单呢?
一点用也没有,这处程序
If i want to interact with C#,how to get the confirmation of Yes/No from a javascript pop up;i tried it ever with the following code.but i failed it .When i run it ,there is one error information said document.form1.hdnbox is empity or not a object.what’s wrong ?can you tell me?thank you!
The code is as following:
Response.write("<script language="javascript">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>");
I want know,too
我怎么获取的值为空啊
我的这篇文章中有代码
不好意思。
要获得JavaScript弹出窗口Yes/No值,无非想通过JavaScript弹出窗口确认用户是否同意。
http://blog.csdn.net/ohiolee/archive/2005/01/28/CsharpDotNETButtonConfirm.aspx
这里可以完成以上功能
i know,thanks
nice 🙂
我想请问高手:
在c#中,用以下代码:
Response.write("<script languge=’javascript’");
Response.write("confirm(‘Is it your confirmation…..?’)");
Response.write("</javascript>");
在弹出确认窗口后,如何在c#中获得确认的true or false
我也很想知道,请教啊
为什莫这个问题 没有人回答阿?
有没有人知道啊!?请把答案发出来吧!谢了!!!!!