开发者

using jquery with elements inside a asp:gridview

i 开发者_StackOverflowam trying to add some style with jquery to some elements inside a grid-view but jquery cannot identify those element. i am trying something like this

$("name").css("border", "3px solid red");

thanks


The problem is that .net creates big long ugly names by default. You may call your select "myinput" but .net turns that into something like "somebiguglylongcontainerid$myinput". So when you try to find just "#myinput" with jquery, you can't because it doesn't exist.

There are two solutions. If you are using a late enough version of .net, you can simply set ClientIDMode="static", and this will stop the .net renaming, so it will in fact be called "myinput".

The other solution is to inject the generated ID into your jquery with inline code. $("#<%=myinput.ID%>").css("border", "3px solid red");.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜