在asp.net中生成Windows警报框 [英] generate windows alert box in asp.net

查看:55
本文介绍了在asp.net中生成Windows警报框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

专家,

我正在开发应用程序,因为我限制了总记录的大小,但是我想生成一个Windows警报框以通知超出限制


谢谢

hi experts,

I am developing a application in that i restricted size of total records,but i want to generate a windows alert box to notify that limits are exceed


Thanks

推荐答案

private void MessageBox(string message)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "My title", "alert('" + message + "');", true);
            return;
        }


您可以使用
You can use
Response.Write("<script>window.alert('Inserted')</script>");


通过代码或直接在Design中编写脚本


by code or directly script it in Design


您最好的方法是在JavaScript中使用客户端警报(...).如果这是对某种数据提交的响应,则您的AJAX响应处理程序需要执行此操作;如果它是对客户端事件的响应,那么无论您在哪里尝试添加行,都应该这样做.

但是,模型对话框很烦人,通常,Web用户除非看到严重错误就希望看不到它们.考虑在页面内显示非模式错误,并且理想情况下使其无法通过进行预验证来获取错误(例如,如果无效的话,则禁用``提交/添加行''链接).

请记住,某些浏览器允许用户关闭警报,默认情况下,在页面创建了一些页面之后,会提供此页面没有更多警报"选项. (在Chrome浏览器中,我认为您会在第三本书上看到它.)之后,如果用户将它们关闭,则您通过alert()发送的所有内容都将丢失.因此,请勿将alert()用于重要信息,而应使用阻止进一步互动的页内覆盖.
The best you can do is to use client-side alert(...) in JavaScript. If this is in response to some sort of data submission then your AJAX response handler needs to do it; if it''s in response to client side events then wherever you are trying to add rows, you should do it.

However, model dialogs are annoying and generally web users expect not to see one unless they do something badly wrong. Consider having a non-modal error display within the page, and ideally make it impossible to get the error by doing pre-validation (e.g. disabling the Submit/Add Rows links if they would not be valid).

Bear in mind that some browsers let the user turn off alerts, and by default provide a ''No more alerts from this page'' option after a page has created a few. (In Chrome I think you get that on the third one.) After that, anything you send through alert() is simply lost if the user has turned them off. So don''t use alert() for critical information, instead use an in-page overlay that blocks further interaction.


这篇关于在asp.net中生成Windows警报框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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