How to call javascript function from c#

前端 未结 7 1573
盖世英雄少女心
盖世英雄少女心 2020-12-11 19:18

I like to call a JavaScript function from c#. Can any one can give me code snippet.

More detail...

I have a asp.net page which has a asp button. when i click

7条回答
  •  我在风中等你
    2020-12-11 20:12

    On the assumption that you're coding in ASP.NET (including MVC), calling a JavaScript function would mean embedding the call in JavaScript into your ASPX code, like so:

    
    

    You do have the opportunity to pass information from your C# to the JS call, just as you would have any other code alter the results of your ASPX:

    
    

    This is really stretching the definition of "calling JavaScript from C#" though. What you're doing is having your C#/ASPX code generate HTML/JavaScript, which the browser then interprets as it would any other HTML/JS (regardless of how it was generated).

    Perhaps you could explain what you're trying to do a bit more.

提交回复
热议问题