Javascript function in a web usercontrol
-
i am creating a usercontrol that contains 2 textboxes and a button.textboxes are web controls .i want to check when i click in button whether textboxes contains value or not? is it possible to write a javascript function inside a usercontrol? i tried if(document.getElementById('Name').value=="") { alert("Name can't be empty"); } but it's not working? with regards, Anu
-
i am creating a usercontrol that contains 2 textboxes and a button.textboxes are web controls .i want to check when i click in button whether textboxes contains value or not? is it possible to write a javascript function inside a usercontrol? i tried if(document.getElementById('Name').value=="") { alert("Name can't be empty"); } but it's not working? with regards, Anu
anujose wrote:
if(document.getElementById('Name').value=="")
You will get error on this line, if control
Name
is a server control. This happens because ASP.NET appends user control name with the server side controls to make control id unique. So you need to view source of the page and find out how your control is rendered. Usually it will be likeusercontrolname_controlname
. Find this name and use that in javascript.
-
i am creating a usercontrol that contains 2 textboxes and a button.textboxes are web controls .i want to check when i click in button whether textboxes contains value or not? is it possible to write a javascript function inside a usercontrol? i tried if(document.getElementById('Name').value=="") { alert("Name can't be empty"); } but it's not working? with regards, Anu
-