1
    <script type="text/javascript">
            /* <![CDATA[ */
            var on_id = 1;

     if (<%=GetValue() %>) {
                on_id  = <%=GetValue() %>; 
            }
   </script>

I do get 2 syntax errors: at the 2nd closed brachet: after %> and at ; after again %>. GetValue() is a public decimal method defined in code behind.

How can I achieve this?

4
  • that <![CDATA[ thingy looks suspicious. Commented Jun 29, 2015 at 6:41
  • @TheParamagneticCroissant Its part of the asp code.. Ads it automatically if I am not mistaken Commented Jun 29, 2015 at 6:42
  • Try removing it from your code and running it once as well, apart from removing it from question Commented Jun 29, 2015 at 6:42
  • Why not use a AJAX call?? Commented Jun 29, 2015 at 6:45

3 Answers 3

1

im not an expert but i had faced a similar problem.it got solved by putting <%=GetValue() %> in ''(single quotes) i.e '<%=GetValue() %>' so i stopped getting syntax errors

use parseFloat() function to get the float value from the string

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

1 Comment

i dont think it matters.did you try running it. debug it on the browser and see if its working.
0
 $.ajax({
      type: "POST",
      url: 'yoururl/GetValue',
      data: "{}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
     success: successFunction,
    error: errorFunction
    });

Do it using an AJAX call :)Check the condition in successhandler

Comments

0

Try this

   <script type="text/javascript">
        var on_id = 1;
        <%if (GetValue()) {%>
            on_id  = '<%=GetValue() %>'; 
        <%}%>
   </script>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.