javascipt document.getElementByID() problem using MasterPage
-
hai i new to using masterpage when i use this code any of page in my website javascript code appears how to overcome this problem very urgent <script language=javascript>function test() { alert(document.getElementById("editName").value)); } </script> but without using masterpage this code working perfectly
-
hai i new to using masterpage when i use this code any of page in my website javascript code appears how to overcome this problem very urgent <script language=javascript>function test() { alert(document.getElementById("editName").value)); } </script> but without using masterpage this code working perfectly
sivaprakas wrote:
function test() { alert(document.getElementById("editName").value)); }
This would work with normal pages. But in MasterPages, it is different. Even though you have given the ID as "editname" ASP.NET appends a prefix of the contentplaceholder name along with the actual name. To overcome this, you can set the JavaScript call at runtime from the CodeBehind using editname.ClientID property as parameter to the JS function rather than hardcoding it.
[Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot
-
sivaprakas wrote:
function test() { alert(document.getElementById("editName").value)); }
This would work with normal pages. But in MasterPages, it is different. Even though you have given the ID as "editname" ASP.NET appends a prefix of the contentplaceholder name along with the actual name. To overcome this, you can set the JavaScript call at runtime from the CodeBehind using editname.ClientID property as parameter to the JS function rather than hardcoding it.
[Venkatesh Mookkan] My: Website | Yahoo Group | Blog Spot
Hi thanks for all reply i use "ctl00$ContentPlaceHolder1$editName" as ID and comeout from the pbm
-
Hi thanks for all reply i use "ctl00$ContentPlaceHolder1$editName" as ID and comeout from the pbm
sivaprakas wrote:
"ctl00$ContentPlaceHolder1$editName" as ID and comeout from the pbm
Hard coding this is a bad practice. Once you changes the content place holder name, your script will stop functioning. You should use ClientId which is the correct solution.
All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions