2

Is there any way to assign ASP variable between jquery function is executing?

<%
txtDescription = Replace(strBody,vbCrLf,"<br/>")
%>
<script type="text/javascript" language="JavaScript">
    var bodyDefault = '<%=strBodyDefault%>';
    var txtDescription = '<%=txtDescription%>';
    $(document).ready(function() 
    {
      $("#obj_edit_editBox").focus(function()
      {
          if (txtDescription == bodyDefault)
          {
        //Do something here
          }
      });                          
    });
</script>
6
  • Your code should work fine. Are you having a problem with it? Commented May 18, 2011 at 8:20
  • Hi Rory, in the place Do something here .. How can I assign asp variable to empty i.e., txtDescription = "".. I'm stuck up at this point.. Commented May 18, 2011 at 8:54
  • If your ASP variable txtDescription is empty or null, then nothing would be ouput in the response.write and var txtDescription = '' would be written to the page. Commented May 18, 2011 at 8:57
  • What are you trying to accomplish in Do something? Commented May 18, 2011 at 9:16
  • 1
    Siva: In your case I think that you need to create an input field named Description and set the values in it. Then you need to submit (using a FORM POST) the values to the server. I think that you are no understanding how web development works. Commented May 18, 2011 at 10:34

1 Answer 1

1

The ASP variables are vanishes as soon as the server ends generating the page and send it to the client. There (in the client) you can play with javascript and then post back to the server (via POST or GET) to process the info.

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

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.