开发者

How to pass a value from the serverside page to a function in .JS file in asp.net

I have to pass a string value from the serve开发者_如何学Pythonr side page (.aspx.cs) to a function in .JS page. I need to call the function in JS page from server side page along with string as a parameter.

Can anyone please help me by providing samples or ideas to solve this problem?


If you want to call a JS method with a server-side variable, you can do something like this:

Page.ClientScript.RegisterStartupScript("SomeKey", "functionToCall('" + stringValueOnServer + "');", true);

This renders functionToCall('value'); so that the proper call happens, but functionToCall must be defined before this. Basically, have the script pretty high up in the page.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜