添加RUNAT ="服务器"改变了布局的行为

编程入门 行业动态 更新时间:2024-10-25 22:28:47
本文介绍了添加RUNAT ="服务器"改变了布局的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一些控件,用户控件等页面。

I have a page with some controls, usercontrols etc.

当我改变从纯&LT一个div; DIV ID =foo的> 到< D​​IV ID =foo的RUNAT =服务器> 布局完整的变化。

when I change a div from plain <div id="foo"> to a <div id="foo" runat="server"> the layout complete changes.

这是为什么,以及如何我可以prevent呢?

why is that and how can I prevent it?

我使用.NET Framework 2.0的

I'm using 2.0 .NET framework

是因为.NET改变了我的身份证,这显然我不想要?

Is it because .NET changes my id, which obviously I don't want?

推荐答案

如果你在打靶CSS股利控件的ID,然后运行在服务器上的控制,你会发现它不再适用的风格。

If you're targetting the ID of the div control in CSS and then running the control at server, you'll find it no longer applies the style.

这是因为ASP.NET有一个内置的机制(作INamingContainer),以确保比你不能有多个控制同名做。它让你最终加入容器prefixes做到这一点:

This is because ASP.NET has a built in mechanism (INamingContainer) to ensure than you don't have multiple controls named the same. It does this by adding container prefixes so you end up with:

<div id="ctl00_ctl00_myDivName" runat="server" />

解决这个问题的最简单的方法是将其从上一个ID的工作变成一个类工作:

The easiest way around this is to change it from working on an ID to working on a class:

<div class="myDiv" runat="server"></div>

另外,我认为,XHTML要求的div已关闭标签,以便用

Alternatively, I believe that XHTML requires that Divs have closing tags so use

<div runat="server">Some content</div>

更多推荐

添加RUNAT =&QUOT;服务器&QUOT;改变了布局的行为

本文发布于:2023-06-08 03:56:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/576188.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布局   服务器   改变了   RUNAT   QUOT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!