如何将msg从服务器端传递给javascript? [英] How to pass msg from server side to javascript ?
本文介绍了如何将msg从服务器端传递给javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hai
如何将msg从服务器端传递到javascript并在警告信息中显示?
确实我将在服务器端的此代码中使用来调用javascript并显示alert msg
如果 不 ClientScript.IsClientScriptBlockRegistered( afterDownload)然后
ClientScript.RegisterClientScriptBlock( Me 。 GetType , afterDownload, testmsg(), True )
结束 如果
和javascript是
var frameTimer;
function testmsg(){
if (frameTimer!= null ){
clearInterval(frameTimer);
}
var hiddenFrame = document .getElementById( hiddenFrame);
if (hiddenFrame == null ){
frameTimer = setTimeout( testmsg(), 800 );
return ;
}
alert( Hello World 跨度>);
}
上面的代码正常工作并显示Hello world警报消息,但我需要在testmsg中传递消息()并在警告信息中显示需要更改消息
解决方案
代码:[如果需要,转换为VB]
ScriptManager.RegisterStartupScript(this.Page,this.GetType(),Alert,< script type ='text / javascript'> testmsg('这是你想要的警报');< /脚本>,false);
JavaScript:
< script 类型 = text / javascript >
function testmsg(msg){
alert(msg);
}
< / script > 跨度>
hai
How to pass msg from server side to javascript and show in alert msg ?
actuall i will use in this code in server side to call javascript and show alert msg
If Not ClientScript.IsClientScriptBlockRegistered("afterDownload") Then
ClientScript.RegisterClientScriptBlock(Me.GetType, "afterDownload", "testmsg()", True)
End If
and in javascript is
var frameTimer;
function testmsg() {
if (frameTimer != null) {
clearInterval(frameTimer);
}
var hiddenFrame = document.getElementById("hiddenFrame");
if (hiddenFrame == null) {
frameTimer = setTimeout("testmsg()", 800);
return;
}
alert("Hello World");
}
the above code work correctly and show "Hello world" alert msg,but my need is pass msg in testmsg() and show in alert msg.that is need to change message
解决方案
Code:[Convert to VB if required]
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "<script type='text/javascript'>testmsg('This is the alert you want');</script>", false);JavaScript:
<script type="text/javascript"> function testmsg(msg) { alert(msg); } </script>
这篇关于如何将msg从服务器端传递给javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文