How to find the Link button control in Datalist control usibng Javscript Code
-
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); } } ------------------------------------------------------------- ----------------------------------------------------------------
-
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); } } ------------------------------------------------------------- ----------------------------------------------------------------
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 accordinglyCheers!! Brij Check my latest Article :Exploring ASP.NET Validators
-
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); } } ------------------------------------------------------------- ----------------------------------------------------------------
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