CSS Style Not Working With ID

后端 未结 3 1360
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 07:49

I am using asp.net/C# for my project.Currently i have a default.aspx page and a master page.The default.aspx page has many controls , and

3条回答
  •  花落未央
    2021-01-21 08:40

    The ID on server controls is automatically generated and is not the same as the generated ID on the client side.

    You can find what the generated ID with be with this: <%# txtCustNo.ClientID %>

    ASP.NET 4 supports a new ClientIDMode property on the Control base class. The ClientIDMode property indicates how controls should generate client ID values when they render. The ClientIDMode property supports four possible values:

    1. AutoID—Renders the output as in .NET 3.5 (auto-generated IDs which will still render prefixes like ctrl00 for compatibility)
    2. Predictable (Default)— Trims any “ctl00” ID string and if a list/container control concatenates child ids (example: id=”ParentControl_ChildControl”)
    3. Static—Hands over full ID naming control to the developer – whatever they set as the ID of the control is what is rendered (example: id=”JustMyId”)
    4. Inherit—Tells the control to defer to the naming behavior mode of the parent container control

    When using ASP.Net before 4.0 you have to live with the auto generated ID's.

    For more info on the 4.0 features see this link.

    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

提交回复
热议问题