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. How to find the Link button control in Datalist control usibng Javscript Code

How to find the Link button control in Datalist control usibng Javscript Code

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavascripttutorial
3 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.
  • C Offline
    C Offline
    ChandrakanthGaddam
    wrote on last edited by
    #1

    Hi, This is from chandrakanth. working on dotnet. Actually i got one problem with javascript in button click event. i have one Datalist control. In that Datalist control i have one Linkbutton. I am trying to find the ID of Link button ID through Javascript. But it is giving error here "obj.substring(0, 60);" --Object does not support this property"; Please see the below my Javascript code which i am using. --------------------------------------------------------------- 'sidebar' -- divtag id function SwitchMenus() { var divObj = document.getElementById('sidebar'); var objdatalist = document.getElementById('<%#dlstToDoList.ClientID%>;').childNodes[0]; var obj = objdatalist.getElementsByTagName('ctl00_dlstToDoList_ctl00_lnkTodo'); -- Link button id if (divObj.style.width == "22%") { divObj.style.width = "26%"; divObj.align = "left"; objdatalist.style.width = "100%"; obj.substring(0, 60); } else { divObj.style.width = "22%"; divObj.align = "left"; obj.substring(0,40); } } ------------------------------------------------------------- ----------------------------------------------------------------

    B A 2 Replies Last reply
    0
    • C ChandrakanthGaddam

      Hi, This is from chandrakanth. working on dotnet. Actually i got one problem with javascript in button click event. i have one Datalist control. In that Datalist control i have one Linkbutton. I am trying to find the ID of Link button ID through Javascript. But it is giving error here "obj.substring(0, 60);" --Object does not support this property"; Please see the below my Javascript code which i am using. --------------------------------------------------------------- 'sidebar' -- divtag id function SwitchMenus() { var divObj = document.getElementById('sidebar'); var objdatalist = document.getElementById('<%#dlstToDoList.ClientID%>;').childNodes[0]; var obj = objdatalist.getElementsByTagName('ctl00_dlstToDoList_ctl00_lnkTodo'); -- Link button id if (divObj.style.width == "22%") { divObj.style.width = "26%"; divObj.align = "left"; objdatalist.style.width = "100%"; obj.substring(0, 60); } else { divObj.style.width = "22%"; divObj.align = "left"; obj.substring(0,40); } } ------------------------------------------------------------- ----------------------------------------------------------------

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      chandragaddam wrote:

      obj.substring(0, 60);

      what are you trying to do here? you are trying to use substring() method with an object, so it wont work .this function work with strings. make the changes accordingly

      Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

      1 Reply Last reply
      0
      • C ChandrakanthGaddam

        Hi, This is from chandrakanth. working on dotnet. Actually i got one problem with javascript in button click event. i have one Datalist control. In that Datalist control i have one Linkbutton. I am trying to find the ID of Link button ID through Javascript. But it is giving error here "obj.substring(0, 60);" --Object does not support this property"; Please see the below my Javascript code which i am using. --------------------------------------------------------------- 'sidebar' -- divtag id function SwitchMenus() { var divObj = document.getElementById('sidebar'); var objdatalist = document.getElementById('<%#dlstToDoList.ClientID%>;').childNodes[0]; var obj = objdatalist.getElementsByTagName('ctl00_dlstToDoList_ctl00_lnkTodo'); -- Link button id if (divObj.style.width == "22%") { divObj.style.width = "26%"; divObj.align = "left"; objdatalist.style.width = "100%"; obj.substring(0, 60); } else { divObj.style.width = "22%"; divObj.align = "left"; obj.substring(0,40); } } ------------------------------------------------------------- ----------------------------------------------------------------

        A Offline
        A Offline
        Arindam Tewary
        wrote on last edited by
        #3

        chandragaddam wrote:

        "obj.substring(0, 60);"

        As per your query , you have problem in the above line. What you have written is bound to get an error like that. Because, "obj" is a reference to a control. And as control does not have substring method in javascript you get this error. You should call obj.innerText or obj.value which ever is applicable in your case( depending upon what the control is rendered in your browser for your code) then call the substring method.

        Thanks, Arindam D Tewary

        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