how to call javascript function from ascx page??
-
Hi friends, i am fine and hope u so... I am having commom.js file which contains all the validations.... i like to call one of the function from ascx page while i am clicking the button in ascx page....for validation.... i have tried with Page.RegisterClientScriptBlock,but i couldn;t..can anyone explain the way to do it?? thanks in advance... sarala.s
-
Hi friends, i am fine and hope u so... I am having commom.js file which contains all the validations.... i like to call one of the function from ascx page while i am clicking the button in ascx page....for validation.... i have tried with Page.RegisterClientScriptBlock,but i couldn;t..can anyone explain the way to do it?? thanks in advance... sarala.s
When you add a user control to a aspx page the client id of the normal ASP.NET controls that you have used in the user control are different from the normal ones. Your javascript function need to find the control by its new control name and then validate it. You can do it by either passing the control's client id to the javascript when you register the javascript call, or view the source to get the client id and then hard code it in the javascript function. The first method is better and allows you to use the same validation function across all pages with multiple instances of the user control.