将所有jquery代码放到Javascript文件引发错误时 [英] When Place all jquery code to Javascript file raising error
问题描述
Hi Everyonr,
我有一个母版页和一个内容页面,我已经为文本框和下拉列表编写了一些验证,所有验证工作正常,当我将所有脚本代码放在javscript文件中引发错误,我使用服务器标签,如
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
<%= txtname.ClientID %>
bcoz txtname位于内容页面中。错误也在
bcoz txtname is in content page. and error is also at
<%= controlname%>
仅限行。如果有人知道请帮我解决这个问题。
line only. If anyone knows please help me to sort out this problem.
推荐答案
这里有区别.........请注意'< ;%= txtname.ClientID%>'标签.....以撇号(')开始和结束
.................
here is the difference ......... Please make your attention in the '<%= txtname.ClientID %>' tag.....started and ended with a Apostrophe (’)
.................
alert('<%= txtname.ClientID %>');
var V = <%= txtname.ClientID %>
alert(V);
如果你想控制一个js文件,那么在ASPX页面做这样的事情
and if you want to a control to a js file then do somthing like this in ASPX page
var V = document.getElementById('<%=txtName.ClientID%>');
Or
var V1 =
(' #' + ' <%= txtName .ClientID%GT;'跨度>);
myfunction(V1);
('#' + '<%=txtName.ClientID%>'); myfunction(V1);
和.js文件读取值
and in .js file read the value
function myfunction(V) {
alert(V.value);
}
如果要使用它,则无法将其放在母版页的body标签中我希望工作:)
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 :)
这篇关于将所有jquery代码放到Javascript文件引发错误时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!