locked
how to assign value to session variable? RRS feed

  • Question

  • User1042252450 posted

     

    hi all,

     

      Is it possible to assign the server control value to session variable in javascript?

     if so please help me how to do? or anyother possible way?

     Thanks!

    Friday, August 29, 2008 2:29 AM

Answers

  • User-1034726716 posted


      Is it possible to assign the server control value to session variable in javascript?

     if so please help me how to do? or anyother possible way?

    As far as I know you cant, since Sessions are stored on server, while JavaScript is running on the client. You could possible use HiddenField Control and assign the the value in it via JavaScript and set your Session values with the value of HiddenField control at the server side as demonstrated by HeartAttack...

    Have a look at the following link below for similar issue:

    http://forums.asp.net/t/1312549.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 29, 2008 4:02 AM

All replies

  • User-1179452826 posted

    No.

    But you can assign a value to a hidden runat='server' variable and use that in Page_Load with

    if(Page.IsPostBack)

    {

        Session["key"] = hiddenInput1.Value;

    }

    Friday, August 29, 2008 3:46 AM
  • User-1034726716 posted


      Is it possible to assign the server control value to session variable in javascript?

     if so please help me how to do? or anyother possible way?

    As far as I know you cant, since Sessions are stored on server, while JavaScript is running on the client. You could possible use HiddenField Control and assign the the value in it via JavaScript and set your Session values with the value of HiddenField control at the server side as demonstrated by HeartAttack...

    Have a look at the following link below for similar issue:

    http://forums.asp.net/t/1312549.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 29, 2008 4:02 AM