开发者

call javascript function with parameter from code behind

hii, i have to call a function to display a google map. the code is in .aspx page and i have to call the function from the corresponding .aspx.cs page. my problem is that when i call the function without any parameter it works fine and the map is displayed. however as soon as i try to send a string as argument the map doesnt get displayed. !!

Page.ClientScript.RegisterStartupScript(Type.GetType("System.开发者_开发问答String"), "addScript", "initialize()", true);

when i use this statement the map gets displayed. but when i write

Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "addScript", "initialize('" + finaladd + "','" + name_and_add + "')", true);

its not worknig.. finaladd and name_and_add are two strings. they are however quite long ones.


Make sure that both finaladd and name_and_add are properly escaped. In this case you need to make sure that the strings don't contain any single quote ' character.

The easiest way to accomplish this is a simple .Replace("'", @"\'") on both variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜