未显示Javascript警报 [英] Javascript alert not displayed

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

问题描述

这是代码隐藏代码

 ScriptManager.RegisterStartupScript( this ,GetType(),   alertMessage
alert(测试消息 ); true );



但警报信息不会显示。

但如果这样编码,则此消息会显示在页面顶部

 ScriptManager.RegisterClientScriptBlock( this  this  .GetType(), 通知  alert('通知:您的消息。'); true ); 



希望你能暗示我的原因。对于第二个我修改并试过,但它不起作用

  string  s =  通知:您的消息。; 
ScriptManager.RegisterClientScriptBlock( this this .GetType(), 通知 alert( + s + ););



您能提供咨询吗?谢谢。



我尝试过:



未显示JavaScript警报

解决方案

区别在于它被渲染的地方。否则,没有区别。请参阅 - 在asp.net中的RegisterStartupScript与RegisterClientScriptBlock - dotnetprof [ ^ ]。



您没有正确使用第二个。尝试如下。

 ClientScript.RegisterClientScriptBlock( this  .GetType(),  sample  alert('测试消息') true ); 


尝试

  //   
ScriptManager.RegisterStartupScript( this ,GetType(), alertMessage alert('Test Message'););
// 或(当使用更新面板时)
ScriptManager < /u>.RegisterClientScriptBlock( this this .GetType(), alert alert ('我的消息'); true );





使用单引号表示警告信息字符串





  string  s =  通知:你的消息。; 
ScriptManager.RegisterClientScriptBlock( this this .GetType(), 通知 alert(' + s + '););


This is the code-behind code

ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage",
    "alert("Test Message");", true);


But the alert message does not display.
But if coded like that, this message displays on the top of the page

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('Notification : Your Message.');", true);


Wish you can hint me why. For the 2nd one I revised and tried, but it does not work

string s = "Notification : Your Message.";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert(" + s + ");", true);


Could you provide your advisory? Thanks.

What I have tried:

JavaScript alert not displayed

解决方案

The difference is the places where it gets rendered. Otherwise, there is no difference. Refer - RegisterStartupScript vs RegisterClientScriptBlock in asp.net - dotnetprof[^].

You have not used the second one correctly. Try like below.

ClientScript.RegisterClientScriptBlock(this.GetType(), "sample", "alert('Test Message')", true);


try

// this 
 ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage",  "alert('Test Message');", true);
// or  (when using update panel)
 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('my message');", true);



use single quotes for alert message string


string s = "Notification : Your Message.";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('" + s + "');", true);


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

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