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. Javascript Problem in asp.net in Content page

Javascript Problem in asp.net in Content page

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-nethelp
6 Posts 4 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.
  • S Offline
    S Offline
    sharad Pyakurel
    wrote on last edited by
    #1

    I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.

    P S V 3 Replies Last reply
    0
    • S sharad Pyakurel

      I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.

      P Offline
      P Offline
      PSK_
      wrote on last edited by
      #2

      In javascript to set the value of a label instead of using value property use innerText. Like

      ctrl.innerText ='Something';

      In case of dropdown list you need to iterate the collection and compare each value in the option collection.

      for(var i=0;i
      WWW, WCF, WWF, WPF, WFC .... WTF

      1 Reply Last reply
      0
      • S sharad Pyakurel

        I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.

        S Offline
        S Offline
        sashidhar
        wrote on last edited by
        #3

        try this

        document.getElementById('<%= lblEndTime.ClientID %>''.innerText=value

        LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

        1 Reply Last reply
        0
        • S sharad Pyakurel

          I am trying to set value in Label and Dropdown list in Asp.net content page from external javascript file. I did for textbox by passing ClientID of TextBox through parameter as: function setValueInTextBox(ctrVal) { ctrVal.value="strvalue"; } and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")"); This works for TextBox. But i unabled to set values in Label and Dropdownlist controls. What should i do, please suggest me.

          V Offline
          V Offline
          Venkatesh Mookkan
          wrote on last edited by
          #4

          sharad Pyakurel wrote:

          and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")");

          Change this to,

          btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");

          Castle Rider

          What if I freeze??? Don't forget to breath...

          My: Website | Yahoo Group | Blog Spot

          S 1 Reply Last reply
          0
          • V Venkatesh Mookkan

            sharad Pyakurel wrote:

            and in cs file: btnSet.Attributed.Add("onClick","setValueInTextBox("+txtValue.ClientID+")");

            Change this to,

            btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");

            Castle Rider

            What if I freeze??? Don't forget to breath...

            My: Website | Yahoo Group | Blog Spot

            S Offline
            S Offline
            sharad Pyakurel
            wrote on last edited by
            #5

            Thankyou Castle Rider. It worked. btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");

            V 1 Reply Last reply
            0
            • S sharad Pyakurel

              Thankyou Castle Rider. It worked. btnSet.Attributed.Add("onClick","setValueInTextBox(document.getElementById('"+txtValue.ClientID+"'))");

              V Offline
              V Offline
              Venkatesh Mookkan
              wrote on last edited by
              #6

              You are welcome. You can mark it as Answer if it helped you... :-D

              Castle Rider

              What if I freeze??? Don't forget to breath...

              My: Website | Yahoo Group | Blog Spot

              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