Click here to Skip to main content
15,901,761 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Everyonr,

I have a master page and a content page, I have written some validations for textbox and drop downlists and all validations are working fine, When i place all the script code in javscript file raising errors , i'm using server tags like
JavaScript
<%= txtname.ClientID %>
bcoz txtname is in content page. and error is also at
JavaScript
<%= controlname%>
line only. If anyone knows please help me to sort out this problem.
Posted
Comments
[no name] 23-Jul-13 6:34am    
Share the error you are getting....
Dholakiya Ankit 24-Jul-13 0:29am    
put ur full code i am giving u solution
Rockstar_ 23-Jul-13 6:36am    
While debugging through Chrome browser getting error
Rockstar_ 23-Jul-13 6:37am    
Error:
Uncaught Error: Syntax error, unrecognized expression: #<%=btnCompare.ClientID%>
Dholakiya Ankit 23-Jul-13 6:38am    
have u put this code in head tag?????? if yes then see my solution

here is the difference ......... Please make your attention in the '<%= txtname.ClientID %>' tag.....started and ended with a Apostrophe (’)
.................


JavaScript
alert('<%= txtname.ClientID %>');

var V = <%= txtname.ClientID %>
        alert(V);


and if you want to a control to a js file then do somthing like this in ASPX page

JavaScript
var V = document.getElementById('<%=txtName.ClientID%>');
Or
            var V1 = $('#' + '<%=txtName.ClientID%>');
            myfunction(V1);


and in .js file read the value

JavaScript
function myfunction(V) {
    alert(V.value);
}
 
Share this answer
 
in master page head tag server controls cant be passed if you want to use it place it in a body tag in master page it will works i hope :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900