ASP.NET母版页内容页的标识基于原始元素ID一切都变了,打破CSS?你在跟我开玩笑吗 [英] ASP.NET Master Page Content Page's IDs all changed, breaking CSS based on original element IDs? Are you kidding me

查看:133
本文介绍了ASP.NET母版页内容页的标识基于原始元素ID一切都变了,打破CSS?你在跟我开玩笑吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.NET母版页的内容页面的元素都似乎是具有自己的ID更改或$ P $由ASP.NET页面渲染ppended。

ASP.NET Master Page Content Page's elements all seem to be having their ID's changed or prepended by the ASP.NET page renderer.

这打破了所有的CSS样式在原有基础上元素ID。

This breaks all CSS styles based on the original element IDs.

这是严重的它是如何工作?如果是这样,有没有变通的办法?

Is this seriously how it works? If so, is there a way around it?

推荐答案

是的,你可以指定的ClientIDMode 将其设置为静态。

Yes, you can specify the ClientIDMode set it to static.

例子的:

客户端

<asp:TextBox ID="TextBox1" runat="server" ClientIDMode="Static"></asp:TextBox>

code背后

TextBox txtBox = new TextBox();
txtBox.ID = "TextBox1";
txtBox.ClientIDMode = ClientIDMode.Static

如果设置为静态...

By setting it to static...

的客户端ID值被设置为ID属性的值。如果控制是一个命名容器时,控制被用作命名容器为任何控制,它包含的层次结构的顶部。

The ClientID value is set to the value of the ID property. If the control is a naming container, the control is used as the top of the hierarchy of naming containers for any controls that it contains.

更新 感谢的@克里斯生动的的附加信息


Update thanks to @Chris Lively for the additional info

页面级

<%@ Page Language="C#" ClientIDMode="Static" AutoEventWireup="true"...

应用级

<system.web>
    <pages clientIDMode="Static"></pages>
</system.web>

引用的:


  • <一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode.aspx\">http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode.aspx

<一个href=\"http://beyondrelational.com/blogs/hima/archive/2010/07/16/all-about-client-id-mode-in-asp-net-4.aspx\">http://beyondrelational.com/blogs/hima/archive/2010/07/16/all-about-client-id-mode-in-asp-net-4.aspx

这篇关于ASP.NET母版页内容页的标识基于原始元素ID一切都变了,打破CSS?你在跟我开玩笑吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆