CSS样式不工作有了ID [英] CSS Style Not Working With ID

查看:120
本文介绍了CSS样式不工作有了ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

asp.net/C#我project.Currently我有一个 Default.aspx的页,主PAGE电泳 Default.aspx的页面有许多控制,并为每个控制我已经定义了 ID 。我现在面临的问题是,当我申请使用风格来一个特定的控制类,款式都是正确反映,当我做到这一点使用样式不会反映在控件的ID。
我纠正了问题,但我不知道如何解决。
例如,
我有一个文本 ID =txtCustNo ,,当我申请的风格像

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 for each control i have defined class and id. The problem i am facing is that when i apply style to a particular control using the class , the styles are reflected properly, and when i do that using the id of the control the style is not reflected. I rectified the issue but i dont know how to solve that. For instance, I have a textbox with id="txtCustNo" ,, when i apply style like

#txtCustNo{border:1px solid red}

这亘古不变的反映,,,当我申请的风格像#ctl00_ContentPlaceHolder1_txtCustNo 它显示了变化,但是id是 txtCustNo ..有人能指出我在哪里我要去wrong.Thanks。

it doesnot reflect ,,,when i apply style like #ctl00_ContentPlaceHolder1_txtCustNo it shows the changes , however the id is txtCustNo..Can somebody point me out where am i going wrong.Thanks .

推荐答案

在服务器控件的ID是自动生成的,是不一样的在客户端生成的ID。

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

您可以查找生成的ID与符合本:其中,%#txtCustNo.ClientID%>

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

ASP.NET 4支持在Control基类一个新的ClientIDMode属性。 ClientIDMode属性表示,当他们渲染控制应该如何生成客户端ID值。 ClientIDMode属性支持四个可能的值:

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. 自动识别 - 渲染输出作为.NET 3.5(自动生成的ID,这将仍然呈现prefixes像ctrl00兼容性)

  2. predictable(默认) - 任何剪裁ctl00ID字符串和如果列表/容器控件会连接子ID(例如:ID =ParentControl_ChildControl)

  3. 防静电手在整个ID命名控制开发商 - 无论他们设置控件的ID是什么呈现(例如:ID =JustMyId)

  4. 继承 - 告诉控制推迟到父容器控件的命名行为模式

在4.0之前使用ASP.Net,你必须忍受自动生成的ID的。

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

有关4.0的功能更多信息请参阅此链接。

For more info on the 4.0 features see this link.

<一个href=\"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\" rel=\"nofollow\">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

这篇关于CSS样式不工作有了ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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