0

Is there a way to set an element runat="server" without causing the id to be altered?

I have a master page and a content page. Within this content page is a table with an id of id="fulllist_list_table". If I apply the runat="server" to the tbl element, the id becomes id="ctl00_content_fulllist_list_table. I'd rather that change not occur.

Is there a way to have the above scenario not change the id of the table element?

Code is below.

CONTENT HTML

<%@ Page Language="C#" MasterPageFile="master.master" Inherits="DenApp.fulllist" Title="DenApp - Full List"%>
<asp:content ID="contentInternal" contentplaceholderid="content" runat="server">
<script type="text/javascript">
    $(document).ready(function () {
        $("#master_tabs_div_fulllist").removeClass("master_tabs_links");
        $("#master_tabs_div_fulllist_div").removeClass("master_tabs_tabs");
        $("#master_tabs_div_fulllist_div").addClass("master_tabs_selected");
        $("#fulllist_list_table").tablesorter({
            widgets: ["zebra", "filter"],
            widgetOptions: {
                filter_childRows: false,
                filter_columnFilter: true,
                filter_ignoreCase: true,
                filter_liveSearch: true,
                filter_searchDelay: 100,
                filter_startsWith: true,
            }
        });
        $("#fulllist_list_table").tablesorterPager({
            container: $("#fulllist_paging_div"),
            size: 25,
            output: '{startRow}-{endRow}/{totalRows}',
            cssNext: '#fulllist_paging_div_nextbtn',
            cssPrev: '#fulllist_paging_div_prevbtn',
            cssFirst: '#fulllist_paging_div_firstbtn',
            cssLast: '#fulllist_paging_div_lastbtn',
            cssPageSize: '#fulllist_paging_div_pagesize',
        });


});
</script>
<link rel="Stylesheet" href="./css/fulllist.css" />
    <div id="master_content_wrapper">
        <div id="fulllist_list_div">
            <table id="fulllist_list_table" class="tablesorter" runat="server" clientidmode="Static">
                <thead>
                    <tr>
                        <th>Account Number</th>
                        <th>Patient Name</th>
                        <th>Plan Code</th>
                        <th>Carrier</th>
                        <th>Billed Patient Type</th>
                        <th>Initial Patient Type</th>
                        <th>Denial Code</th>
                        <th>Denial Reason</th>
                        <th>Admit Date</th>
                        <th>Discharge Date</th>
                        <th>Appeal Amount</th>
                        <th>Total Charges</th>
                        <th>Received Date</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>C0000000000</td>
                        <td>Smith, John T</td>
                        <td>000000</td>
                        <td>Insurance</td>
                        <td>PT</td>
                        <td>PT</td>
                        <td>0000</td>
                        <td>Denied</td>
                        <td>01/01/01</td>
                        <td>01/01/01</td>
                        <td>$100.00</td>
                        <td>$100.00</td>
                        <td>01/04/01</td>
                    </tr>
                    <tr>
                        <td>C0000000001</td>
                        <td>Rita, John T</td>
                        <td>000001</td>
                        <td>Insurance</td>
                        <td>PT</td>
                        <td>PT</td>
                        <td>0000</td>
                        <td>Denied</td>
                        <td>02/01/01</td>
                        <td>01/02/01</td>
                        <td>$200.00</td>
                        <td>$1,000,000.00</td>
                        <td>01/04/01</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div id="fulllist_paging_div">
            <div id="fulllist_paging_div_firstbtn" class="fulllist_tablenav">
            </div>
            <div id="fulllist_paging_div_prevbtn" class="fulllist_tablenav">
            </div>
            <div id="fulllist_paging_div_numpages_div" >
                <select id="fulllist_paging_div_pagesize">
                    <option value="10">10</option>
                    <option selected="selected" value="25">25</option>
                    <option value="50">50</option>
                    <option value="100">100</option>
                    <option value="150">150</option>
                    <option value="200">200</option>
                </select>
            </div>
            <div id="fulllist_paging_div_pagedisplay" class="pagedisplay">
            </div>
            <div id="fulllist_paging_div_nextbtn" class="fulllist_tablenav">
            </div>
            <div id="fulllist_paging_div_lastbtn" class="fulllist_tablenav">
            </div>
        </div>
    </div>
</asp:content>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
steventnorris
  • 5,656
  • 23
  • 93
  • 174
  • 1
    I wonder why I do not get that behaviour. I found this: http://stackoverflow.com/questions/4437717/asp-net-2-5-prefixing-ctl00-and-asp-net-4-not-prefixing-ctl00 Might it be, that you're using an older ASP.NET version? – Kai Hartmann Sep 25 '13 at 12:58
  • Our server runs on ASP.NET 2 I believe. We may have recently installed the 3.5 update, but it isn't 4.0. – steventnorris Sep 25 '13 at 13:02
  • 1
    I have no solution, since I think it is not possible to prevent that behaviour in any version before 4.0, but this article at least might give some insight, because things like 'ClientIDMode' are just available >= .NET 4.0: http://weblogs.asp.net/scottgu/archive/2010/03/30/cleaner-html-markup-with-asp-net-4-web-forms-client-ids-vs-2010-and-net-4-0-series.aspx – Kai Hartmann Sep 25 '13 at 13:09
  • 1
    is it posible for you to change your css so that it targets ctl00_content_fulllist_list_table since that name is not going to change ? – Mauricio Gracia Gutierrez Sep 25 '13 at 13:12
  • @KaiHartmann I was hoping that wouldn't be the case, but it is looking that way. Thanks for the information. – steventnorris Sep 25 '13 at 13:14
  • @MauricioGracia I could, and I have in the past. I just think it's a bit less clean, and if my page structure changes in the future, I'll have to alter the css to handle non-changed ids. – steventnorris Sep 25 '13 at 13:15
  • @steventnorris take a look at this http://stackoverflow.com/questions/9629425/css-style-not-working-with-id – Mauricio Gracia Gutierrez Sep 25 '13 at 13:20

1 Answers1

1

Set ClientIDMode to Static to table element.

<table id="fulllist_list_table" runat="server" clientidmode="Static">

As you mentioned in your comment that you are using .Net 2.0 framework, So I would like to tell you that unfortunately ClientIDMode isn't available in before framework 4.0. Look at here for this change

Older version has its value as Auto.

Sachin
  • 40,216
  • 7
  • 90
  • 102
  • the tag now reads , but the id still changes.
    – steventnorris Sep 25 '13 at 12:56
  • How does it changes? how are you accessing this id. can you please show us the code. – Sachin Sep 25 '13 at 12:58
  • Added code above. The id changes to ctl00_content_fulllist_list_table regardless of clientidmode. I know it changes because the formatting applied via css and jquery does not run. Also, when checking the viewsource, i can see the id has changed. I am using .NET 2.0 if that helps. – steventnorris Sep 25 '13 at 13:05
  • @steventnorris - With .NET 2.0 -- Just use the CssClass property for your CSS. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.cssclass%28v=vs.80%29.aspx For your javascript/jquery you can just select it like so: $('#<%= fulllist_list_table.ClientID %>') You can do anything you want so long as you know how to navigate the framework. I've never been restricted with .NET 2.0. – mikey Sep 25 '13 at 13:34