没有页面刷新的警报框 [英] alert box without page refresh

查看:57
本文介绍了没有页面刷新的警报框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有2种类型的javascript对话框可用:

1.警报:其中只有确定"按钮.
2.确认:具有确定"和取消"

但是v如何在asp.net

There are 2 types of javascript Dialog available:

1. alert : which have only OK button in it.
2. confirm : which has Ok and Cancel

but how v can use this without page refresh in asp.net

推荐答案

中不进行页面刷新的情况下使用它,您应该已经编辑了原始问题,因为这仍然是您要问的问题. ASP.NET中网页上的任何按钮都可以具有单击事件,并且可以单击客户端.客户端点击事件将使用javascript,如果返回false,则OnClick不会回发.因此,为避免回发,您只需要在执行回发之前添加代码以显示对话框即可,因此该对话框已在页面中.
You should have edited your original question, as it''s still what you''re asking. Any button on a web page in ASP.NET can have a click event, and a client click. The client click event will be in javascript, and if it returns false, the OnClick will not postback. So, to avoid postback, you simply need to add the code to show the dialog box BEFORE you do a postback, so it''s in the page already.




如果您在页面中使用AJAX,则可以在所需的位置调用此代码

hi man,

if you use AJAX in your page you can call this code on required places

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "test", "alert(''welcome'');");


页面加载,


on page load,

Page.ClientScript.RegisterStartupScript(typeof(Page), "MyScript", "alert(''welcome'');");


就像您应该改善问题一样


same as you should improve the question


我不知道您为什么需要发回信息以显示警报/确认....:confused:

只需在客户端添加警报,就会显示您的警报.

<input type="button" onclick = "javascript:alert(''hi'');" />

现在,如果单击该按钮,它将显示警报. :)
I dont know why you require Postback to show alert / confirm.... :confused:

Just add alert in the client side and your alert will be displayed.

say <input type="button" onclick = "javascript:alert(''hi'');" />

Now if the button is clicked, it will show the alert. :)


这篇关于没有页面刷新的警报框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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