开发者

Call Public variable of C# in javascript?

开发者 https://www.devze.com 2022-12-29 17:10 出处:网络
My Problem is I am 开发者_如何学运维try to call Public variable in Code Behind From JavaScript function

My Problem is I am 开发者_如何学运维try to call Public variable in Code Behind From JavaScript function I try To Do This :

In Code Behind Section:

  public string str ="TEST";

In JavaScript Section:

 <script type="text/javascript" language="javascript">

    function funDoSomething()
    {
        var strMessage = '<%= str%>';
        alert( strMessage );
    }
 </script>

Any Suggestion?


 <script type="text/javascript" language="javascript">    
    function funDoSomething()
    {
        var strMessage = <%= "'" + str + "'"%>;
        alert( strMessage );
    }
 </script>

Ugly but should work.


I found the answer and it is Like this In JavaScript Section:

<script type="text/javascript" language="javascript">

   function funDoSomething()
   {
       var strMessage = "<%=str%>";
       alert( strMessage );
   }
</script>

This Work With Me :)

0

精彩评论

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