显示JavaScript警报消息 [英] show javascript alert message

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

问题描述

我正在尝试显示错误警报框.

这是代码的一部分:

I am trying to show a alert box for an error.

Here is the part of the code:

Catch ex As Exception
    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ExceptionMessage_AuditMain4", "<script type='text/JavaScript'>alert( '" + ex.Message + "');</script>", True)
Finally




但是它不显示警报消息.正在启用自动回发的情况下,从下拉列表的选定索引更改中调用该消息.

页面具有ajax更新面板,我已逐步完成代码以确保该块被触发(执行).




But it doesn''t display the alert message. The message is being called from a selected index change of a dropdownlist with autopostback enabled

Page has ajax update panels and I have step through the code to ensure the block is being tripped (executed).

推荐答案

使用部分页面更新,例如UpdatePanel ,您将无法获得完整的页面生命周期,并且脚本也不会注入响应流中.

一种更常见的方法是通过javascript回调函数将信息传递回客户端,并在其中显示任何错误消息.
Using a partial page update, such with an UpdatePanel, you are not getting the full page life cycle and the script is not being injected into the response stream.

A more common approach is to pass the information back to the client via the javascript callback function and display any error messages there.


Catch ex As Exception
dim msg as string=ex.message
    page.RegisterScriptblock( Me.GetType(), "alert ","alert("' & msg & '"), True)
Finally


这篇关于显示JavaScript警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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