jquery - Why does the ClientID not show up? How to fix -


i have jquery function in asp trying client id of. when renders html result.

[html rendered]

$("")//ctl00_content_gvprogramlist                     .tablesorter({ widthfixed: true, widgets: ['zebra'],                         widgetoptions: {                             zebra: ["even", "odd"]                         }                     })                     .tablesorterfilter({ filtercontainer: $("#filter-box"),                         filterclearcontainer: $("#filter-clear-button"),                         filtercolumns: [0, 1, 2, 3],                         filtercasesensitive: false                     })                     .tablesorterpager({ container: $("#pager") }); 

[code behind]

        $("<%# gvprogramlist.clientid %>")//ctl00_content_gvprogramlist                 .tablesorter({ widthfixed: true, widgets: ['zebra'],                     widgetoptions: {                         zebra: ["even", "odd"]                     }                 })                 .tablesorterfilter({ filtercontainer: $("#filter-box"),                     filterclearcontainer: $("#filter-clear-button"),                     filtercolumns: [0, 1, 2, 3],                     filtercasesensitive: false                 })                 .tablesorterpager({ container: $("#pager") }); 

if use ct100_content_gvprogramlist javascript works should, please don't post answers relating that. want answer on how clientid show correctly.


update

i use $('#<%= gvprogramlist.clientid %>'), error.

the controls collection cannot modified because control contains code blocks (i.e. <% ... %>).   line 16:         head.controls.add(header()) line 17:         head.controls.add(menu()) line 18:         foot.controls.add(footer()) 

use:

<%= ... %> 

instead of:

<%# ... %> 

so:

$('#<%= gvprogramlist.clientid %>') ... 

after update

since you're building/modifying controls collection in code-behind aspnet barfing when try response.write() (<%= ... %>). try using class name instead of control's id.

or:

wrap <script> ... </script> inside <asp:placeholder>. make script child of place holder instead of server-side control causing error.


Comments