0

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?

1
  • 4
    you didn't ask a question actually. Commented May 4, 2010 at 14:55

2 Answers 2

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

Ugly but should work.

Sign up to request clarification or add additional context in comments.

Comments

1

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 :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.