locked
embed session variable in javascript RRS feed

  • Question

  • User-863835478 posted

    Please correct the following javscript where a session variable "branch" is embedded :

    vReturnValue = window.showModalDialog("PRSpecEntry.aspx?branch=<% =Session(""branch"")%>", "", 'dialogHeight:400px; dialogWidth:600px;');

    The above code caused an error.

    Thanks. 

     

    Saturday, March 8, 2008 2:46 AM

Answers

  • User1548900558 posted

    The problem is in the "" in the <% %>, it should be single double quotation since the server is rendering first:

    <%= Session(""branch"")%>

    which is giving the error. Change it to the following:

    vReturnValue = window.showModalDialog('PRSpecEntry.aspx?branch=<% =Session("branch")%>', '', 'dialogHeight:400px; dialogWidth:600px;');

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 8, 2008 4:05 AM

All replies

  • User1412236707 posted

    I think you should cast your session to string:

     vReturnValue = window.showModalDialog("PRSpecEntry.aspx?branch=<% =(string)Session(""branch"")%>", "", 'dialogHeight:400px; dialogWidth:600px;');

    Saturday, March 8, 2008 2:53 AM
  • User-1938403941 posted

    Change Session(""branch"") to Session(""branch"").ToString()

    Saturday, March 8, 2008 3:58 AM
  • User1548900558 posted

    The problem is in the "" in the <% %>, it should be single double quotation since the server is rendering first:

    <%= Session(""branch"")%>

    which is giving the error. Change it to the following:

    vReturnValue = window.showModalDialog('PRSpecEntry.aspx?branch=<% =Session("branch")%>', '', 'dialogHeight:400px; dialogWidth:600px;');

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 8, 2008 4:05 AM