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. General Programming
  3. C#
  4. to get vale in javascript to c#

to get vale in javascript to c#

Scheduled Pinned Locked Moved C#
csharpjavascripthtmltutorialquestion
4 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 Offline
    P Offline
    P_Elza
    wrote on last edited by
    #1

    hi all i have some values on html page in javascript. i want to get that values in C#. how to do that. I tried displaying it on a label, and retreave it from there. This is the function in javascript function display() { var localpath1 = document.getElementById('lblerr'); lblerr.innerText = localpath; }it is diplaying the value on label. lblerr is the id of label. am calling this function on pageload but when i try to get the value using lblerr.text, it is showing null. y is it so? how to get value on the label

    P A 2 Replies Last reply
    0
    • P P_Elza

      hi all i have some values on html page in javascript. i want to get that values in C#. how to do that. I tried displaying it on a label, and retreave it from there. This is the function in javascript function display() { var localpath1 = document.getElementById('lblerr'); lblerr.innerText = localpath; }it is diplaying the value on label. lblerr is the id of label. am calling this function on pageload but when i try to get the value using lblerr.text, it is showing null. y is it so? how to get value on the label

      P Offline
      P Offline
      Prateek G
      wrote on last edited by
      #2

      innerText is a different property its not same as .Text. Make a hidden variable in a form with runat="server" and assign it that value. In .aspx

      In javascript u can write document.getElementById('hdnVar').value = localpath; and in c# lblerr.Text = hdVar.value.ToString(); Try it, It should work. Prateek... Prateek..

      P 1 Reply Last reply
      0
      • P Prateek G

        innerText is a different property its not same as .Text. Make a hidden variable in a form with runat="server" and assign it that value. In .aspx

        In javascript u can write document.getElementById('hdnVar').value = localpath; and in c# lblerr.Text = hdVar.value.ToString(); Try it, It should work. Prateek... Prateek..

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

        i had tried this one also previously. error was occuring the error is System.NullReferenceException:Object reference not set to an instance of an object what is this? how to rectify this.

        1 Reply Last reply
        0
        • P P_Elza

          hi all i have some values on html page in javascript. i want to get that values in C#. how to do that. I tried displaying it on a label, and retreave it from there. This is the function in javascript function display() { var localpath1 = document.getElementById('lblerr'); lblerr.innerText = localpath; }it is diplaying the value on label. lblerr is the id of label. am calling this function on pageload but when i try to get the value using lblerr.text, it is showing null. y is it so? how to get value on the label

          A Offline
          A Offline
          Andrei Ungureanu
          wrote on last edited by
          #4

          P_Elza wrote:

          m calling this function on pageload but when i try to get the value using lblerr.text, it is showing null.

          Try using this:

          if (this.IsPostback)
          {
          string value = Request["lblerr"];
          }

          Hope it helps. PS: Don't open new topics....continue on the one already opened and try explain more detailed.
          Another hint: This is the C# forum...there is an ASP.NET forum also.

          There are 10 kinds of people: those who understand binary and those who don't

          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