从aspx.cs文件调用javascript函数 [英] to call javascript function from aspx.cs file

查看:58
本文介绍了从aspx.cs文件调用javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在for循环中使用Page.Client Script.RegisterStartupScript()函数从.cs文件中调用JavaScript函数,并作为参数传递了纬度和经度以在地图中标记标记,但在循环的最后它仅显示第一个值的标记.

请帮我.

Hi, i am calling a JavaScript function from .cs file using Page.Client Script.RegisterStartupScript() function in a for loop and as parameter i am passing the latitude and longitude for marking markers in map but at the last of loop it is showing only marker for first value only.

Plz Help me.

Thanks.

推荐答案

显示您的代码;谢谢.并非全部...只是足够使我们能够理解.
Show your code; not all of it... just enough so we can get the idea.


您的脚本密钥在每次迭代中必须相同,因此脚本将仅在第一次呈现.

试试这个:
Your script key must be same on each iteration so the script will be rendered only for the first time.

Try this:
for (int i = 0; i < 5; i++)
{
     string loadscript = "alert('" + i + "');";
     string scriptKey = "loadscript" + i.ToString();            
     Page.RegisterStartupScript(scriptKey, "<script language=javascript>"
                        +loadscript+"</script>");
}


必须将不同的脚本键循环在一起.
:thumbsup:


Having different script keys in a loop is necessary.
:thumbsup:


这篇关于从aspx.cs文件调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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