Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. use of session in aspx file.

use of session in aspx file.

Scheduled Pinned Locked Moved ASP.NET
javascripttools
13 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Priyagdpl

    hi, plz, tell me, can we use session in source (javascript function in aspx file) file. if yes then plz tell me syntax of it. My fun is, function PikCode(textid) { String myval = document.getElementById(textid).value; Session["txtcode"] = myval; } <script> but wen i use session in cs file, it become null. Thanx in Advance.</x-turndown>

    V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #2

    <script>

    close the Tag and lets see how you use it in the server side

    Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

    P 1 Reply Last reply
    0
    • V Vimalsoft Pty Ltd

      <script>

      close the Tag and lets see how you use it in the server side

      Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

      P Offline
      P Offline
      Priyagdpl
      wrote on last edited by
      #3

      function PikCode(textid) { String myval = document.getElementById(textid).value; alert('myval'); Session["txtcode"] = myval; } In cs file: string txtcode = Convert.ToString(Session["txtcode"].ToString());

      V 1 Reply Last reply
      0
      • P Priyagdpl

        function PikCode(textid) { String myval = document.getElementById(textid).value; alert('myval'); Session["txtcode"] = myval; } In cs file: string txtcode = Convert.ToString(Session["txtcode"].ToString());

        V Offline
        V Offline
        Vimalsoft Pty Ltd
        wrote on last edited by
        #4

        Ohh sorry This is how the session is used in javascript, it did not see this

        <script language="javascript">
        function PikCode(textid)
        {
        String myval = document.getElementById(textid).value;
        alert('myval');
        <%=Session("txtcode")%>= myval;
        }
        </script>

        Regards Vuyiswa Maseko

        Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

        L 1 Reply Last reply
        0
        • V Vimalsoft Pty Ltd

          Ohh sorry This is how the session is used in javascript, it did not see this

          <script language="javascript">
          function PikCode(textid)
          {
          String myval = document.getElementById(textid).value;
          alert('myval');
          <%=Session("txtcode")%>= myval;
          }
          </script>

          Regards Vuyiswa Maseko

          Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #5

          hi , ur code is giving following error 'System.Web.UI.Page.Session' is a 'property' but is used like a 'method' Thanks , Amit PAtel

          V 1 Reply Last reply
          0
          • L Lost User

            hi , ur code is giving following error 'System.Web.UI.Page.Session' is a 'property' but is used like a 'method' Thanks , Amit PAtel

            V Offline
            V Offline
            Vimalsoft Pty Ltd
            wrote on last edited by
            #6

            What code are you talking about ?

            Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

            P 1 Reply Last reply
            0
            • V Vimalsoft Pty Ltd

              What code are you talking about ?

              Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

              P Offline
              P Offline
              Priyagdpl
              wrote on last edited by
              #7

              <%=Session("txtcode")%> = myval; This statement gives error like, 'System.Web.UI.Page.Session' is a 'property' but is used like a 'method'

              V 1 Reply Last reply
              0
              • P Priyagdpl

                <%=Session("txtcode")%> = myval; This statement gives error like, 'System.Web.UI.Page.Session' is a 'property' but is used like a 'method'

                V Offline
                V Offline
                Vimalsoft Pty Ltd
                wrote on last edited by
                #8

                ohhh ok change the brackets and make them curly, its true its been used like a method while its not its a session. so that means you need to change it so that it looks like this

                <%=Session**["txtcode"]**%> = myval;

                Tell me if it helped Regards

                Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

                P 1 Reply Last reply
                0
                • V Vimalsoft Pty Ltd

                  ohhh ok change the brackets and make them curly, its true its been used like a method while its not its a session. so that means you need to change it so that it looks like this

                  <%=Session**["txtcode"]**%> = myval;

                  Tell me if it helped Regards

                  Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

                  P Offline
                  P Offline
                  Priyagdpl
                  wrote on last edited by
                  #9

                  No, its not working. still session is null. :(

                  V 1 Reply Last reply
                  0
                  • P Priyagdpl

                    No, its not working. still session is null. :(

                    V Offline
                    V Offline
                    Vimalsoft Pty Ltd
                    wrote on last edited by
                    #10

                    ok Please Post the Javascript that you currently have now and the way you access it in the Server side.

                    Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

                    P 1 Reply Last reply
                    0
                    • V Vimalsoft Pty Ltd

                      ok Please Post the Javascript that you currently have now and the way you access it in the Server side.

                      Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

                      P Offline
                      P Offline
                      Priyagdpl
                      wrote on last edited by
                      #11

                      In aspx file, function PikCode(textid) { String myval = document.getElementById(textid).value; <%=Session["code"]%> = myval; } in the cs file, if (!IsPostBack) { txtcode.Attributes["onblur"] = "PikCode('ctl00_ContentPlaceHolder1_txtcode')"; } in the user control i m accessing this session, code is, if (FileUpload1.FileBytes.Length > 0) { if (FileUpload1.HasFile == true) { string txtcode1 = Convert.ToString(Session["code"].ToString()); FileUpload1.SaveAs(Server.MapPath ("~/AdminSection/Products/Chemicals/"+txtcode1+FileUpload1.FileName.ToString())); } } This is my code.

                      L V 2 Replies Last reply
                      0
                      • P Priyagdpl

                        In aspx file, function PikCode(textid) { String myval = document.getElementById(textid).value; <%=Session["code"]%> = myval; } in the cs file, if (!IsPostBack) { txtcode.Attributes["onblur"] = "PikCode('ctl00_ContentPlaceHolder1_txtcode')"; } in the user control i m accessing this session, code is, if (FileUpload1.FileBytes.Length > 0) { if (FileUpload1.HasFile == true) { string txtcode1 = Convert.ToString(Session["code"].ToString()); FileUpload1.SaveAs(Server.MapPath ("~/AdminSection/Products/Chemicals/"+txtcode1+FileUpload1.FileName.ToString())); } } This is my code.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        Hi priya in place of <%=Session["code"]%> = myval;> if i use <%=Session["txtcode"]= "sf"%> then we can assign value but how to assign from java script not able to find out can u tell where u need this. Thanks , Amit Patel

                        1 Reply Last reply
                        0
                        • P Priyagdpl

                          In aspx file, function PikCode(textid) { String myval = document.getElementById(textid).value; <%=Session["code"]%> = myval; } in the cs file, if (!IsPostBack) { txtcode.Attributes["onblur"] = "PikCode('ctl00_ContentPlaceHolder1_txtcode')"; } in the user control i m accessing this session, code is, if (FileUpload1.FileBytes.Length > 0) { if (FileUpload1.HasFile == true) { string txtcode1 = Convert.ToString(Session["code"].ToString()); FileUpload1.SaveAs(Server.MapPath ("~/AdminSection/Products/Chemicals/"+txtcode1+FileUpload1.FileName.ToString())); } } This is my code.

                          V Offline
                          V Offline
                          Vimalsoft Pty Ltd
                          wrote on last edited by
                          #13

                          Try this You are Converting it to string Twice in one code

                          string txtcode1 = Convert.ToString(Session[""code""]);

                          If you did this on the server side, it would have been better, you could have a hidden Field and pass the value and access it in the server side. it think the Problem was that the Session name need two double quotes each. Try it

                          Vuyiswa Maseko, Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers." C#/VB.NET/ASP.NET/SQL7/2000/2005/2008 http://www.vuyiswamaseko.com vuyiswa@its.co.za http://www.itsabacus.co.za/itsabacus/

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups