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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with GetElementID in User Control

Problem with GetElementID in User Control

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-nettoolshelp
2 Posts 2 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.
  • K Offline
    K Offline
    kamalika_kk
    wrote on last edited by
    #1

    :)Hi, I'm programming in asp.net 2003. I designed a search utility using javascript in asp.net. The code wis working well in the asp.net page. I'v a text box called txtSearch. To reference this textbox value, I'm using this javascript in a javascript function called at the onkeypress event of the text box. var pre = document.getElementById ("txtSearch").value;.//(I'm running it in IE 4 now) Now I want to convert it to a user control. :sigh:This statement is not working for the user control. I tried to trap the value with this: var sndr = window.event.srcElement; var pre = sndr.text; alert (pre); the alert showed "undefined".... can u tell me what r the other ways of getting the value?..pls There is no final defeat untill you stop trying.......

    J 1 Reply Last reply
    0
    • K kamalika_kk

      :)Hi, I'm programming in asp.net 2003. I designed a search utility using javascript in asp.net. The code wis working well in the asp.net page. I'v a text box called txtSearch. To reference this textbox value, I'm using this javascript in a javascript function called at the onkeypress event of the text box. var pre = document.getElementById ("txtSearch").value;.//(I'm running it in IE 4 now) Now I want to convert it to a user control. :sigh:This statement is not working for the user control. I tried to trap the value with this: var sndr = window.event.srcElement; var pre = sndr.text; alert (pre); the alert showed "undefined".... can u tell me what r the other ways of getting the value?..pls There is no final defeat untill you stop trying.......

      J Offline
      J Offline
      just3ala2
      wrote on last edited by
      #2

      u have to do some functionality before the getElementById method u need to concat the user control instance id then "_" then the element name like this: var strSearch = "ucUserControl1_" + "txtSearch"; document.getElementById(strSearch ); This way u can access it hope this would help

      Best Regards 3ala2 :)

      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