aspx中的确认对话框 [英] confirmation dialog in aspx

查看:268
本文介绍了aspx中的确认对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有文件(Test.aspx,Test.aspx.vb). Test.aspx中的按钮.按钮名称为计算".当用户单击客户端站点上的计算"按钮时,将显示对话框.对话框中有两个按钮,一个是应用按钮,一个是取消按钮.但是用户将单击应用"按钮.
我会做一些事情,如果用户单击cancel,我会做不同的事情,然后关闭对话框.
我如何在我的项目中使用您的代码.在Test.aspx中有很多textfield,我将从那里获取数据,然后更新到数据库.
非常感谢您
珍妮.

I have the files( Test.aspx ,Test.aspx.vb). The button in Test.aspx. The button name is " Calculate". When the user click on "Calculate" button on client site, the dialog will show . In the dialog will have two button , one is will be apply button, one is cancel. But user will click the apply button.
i will do some thing, if user click cancel , I will do difference thing then close the dialog.
How can I appy your code in my project. In the Test.aspx has alot o textfield , i will get data from there then update to database.
Thank you very much
Jenny.

推荐答案

好吧,您要做的是使用javascript处理此客户端.从javascript方法开始:

Ok, what you have to do is handle this client side with javascript. Start off with the javascript method:

<script type="text/javascript">
function PopupConfimBox() {
    var confirmBox = confirm("My Question here");
    if (confirmBox == true) {
        //If they clicked ok, do what you need to do!
        return (true / false); 
        //return true if you want the page to post back and false if you dont!
    }
    else {
        //If they clicked ok, do what you need to do!
        return (true / false);
        //return true if you want the page to post back and false if you dont!
    }
}
</script>



好的,现在通过OnClientClick事件中的ASP按钮将其链接起来!



Ok, now link this up with your ASP button in the OnClientClick event!

<asp:button id="btnMyMagicButton" runat="server" onclientclick="return PopupConfirmBox()" clientclick="MyServerSideMethod()" text="Click Me!" xmlns:asp="#unknown" />



仅当您的客户端(javascript)方法返回true时,才会调用服务器端方法.



Your server side method will only be called if your client side (javascript) method returns true.


我可以获取文本字段的值并将其保存到
Can I get the value of the textfield and save to the database in
if (confirmBox == true) {// in here? }



谢谢



Thanks


这篇关于aspx中的确认对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆