ASP.NET 控件到 HTML 标记的等效项

发布于 2024-07-13 06:49:15 字数 483 浏览 10 评论 0原文

我正在寻找一个备忘单,它可以让我向 HTML 设计者展示标准 HTML 标记的等效 asp.net 控件。 作为一个例子,将呈现为 HTML

; 和一个将呈现为 HTML 。 我一直在谷歌上搜索这个没有结果。 有人可以发布一个好的备忘单的链接,以便该项目的设计人员可以更清楚地理解 aspx 页面上的标记。

需要明确的是,我想要一个主要 ASP.NET 控件列表的链接,以及它们如何与标准 HTML 相关的描述。 如果这是 PDF 格式或易于阅读和打印的网页,那就太好了。 就我而言,原因是我们有一位非常熟悉 HTML 的 PHP 开发人员来参与我们的项目,并且我觉得如果可以的话,更好地了解标准 ASP.NET 服务器控件将会很有用。递给他这样一份“备忘单”。

我主要指的是 .NET 2.0 框架,但我们也在使用 3.0/3.5。

I'm looking for a cheat sheet that will allow me to show an HTML designer the equivalent asp.net controls for standard HTML tags. As an example the <asp:Panel> will render as an HTML <div> and an <asp:Label> will render as an HTML <span>. I've been googling this to no avail. Can someone post a link to a good cheat sheet so that the designers on this project can understand the markup on the aspx pages more clearly.

To be clear, I would like a link to a list of major ASP.NET controls, with descriptions as to how they would relate to standard HTML. It would be great if this were in PDF format or on an easy to read and print web page. The reason, in my case, would be that we have a PHP developer who is very familiar with HTML coming to work on our project, and I feel it would be useful to have a better understanding of standard ASP.NET server controls if I could hand him such a "cheat sheet".

I'm referring mainly to the .NET 2.0 framework, but we are also doing work with 3.0/3.5.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

数理化全能战士 2024-07-20 06:49:15

这不是一个简单的问题,因为它取决于您所讨论的 .NEt 版本以及有时控件的状态。 例如,1&中的PANEL 1.1 渲染为 TABLE,而在更高版本中它是 DIV。

但总的来说(2/3),这里是:

  • Panel - Div

  • 面板 -- GroupingText="###" 是字段集、图例

  • 标签 - 跨度

  • 按钮 - 输入、类型按钮

  • 链接按钮 - 带 JS 回发脚本的 Href

  • 超链接 - 标准 HREF

  • 图像按钮 - 输入,键入图像

  • 文本框 - 默认为输入,键入文本

  • 文本框 -- 模式 = 密码为输入,键入密码

  • Textbox -- Mode= 多行为Textarea

  • DropDownList - 选择

  • 列表框 - 选择

  • RadioButton - 输入、带有组名的单选

  • 复选框 - 输入、复选框

  • Repeater/Listview --Complex。

  • Gridview - 表格

  • 表格 - 表格

  • 文件 - 输入,类型=文件

    这是基础知识。 更深奥的控件(例如 LOGIN 控件)是一个表格,其中包含一堆赔率和结果。

This isn't a simple question, as it depends on which version of .NEt you're talking about and states of controls sometimes. For example, the PANEL, in 1 & 1.1 render to a TABLE while in later versions it's a DIV.

But overall (for 2/3), here goes:

  • Panel - Div

  • Panel -- GroupingText="###" is Fieldset, Legend

  • Label - Span

  • Button - Input, Type Button

  • Link Button - Href with JS Postback Script

  • Hyperlink - Standard HREF

  • Image Button - Input, Type Image

  • Textbox -- Default is Input, Type Text

  • Textbox -- Mode = Password is Input, type Password

  • Textbox -- Mode= Multiline is Textarea

  • DropDownList - Select

  • Listbox - Select

  • RadioButton - Input, Radio with GroupName

  • Checkbox - Input, Checkbox

  • Repeater/Listview --Complex.

  • Gridview - Table

  • Table - Table

  • File - Input, Type=File

    That's the basics. The more esoteric controls such as the LOGIN control is a table with a bunch of odds an ends within it.

寄人书 2024-07-20 06:49:15

Stephen 的列表非常全面。 不过,我会添加以下注释:

主要取决于已知的 BrowserCaps

1.x 面板将在 IE6+ 中呈现为 div - 然而在 Firefox(或其他“DownStream”浏览器 - 被视为 DownStream,因为默认情况下 Machine.Config 中没有详细信息)它将呈现为单个单元格表 -这可以通过在 Machine.Config 或 Web.Configs 中为 Firefox/Opera/Safari/等提供更新的 BrowserCaps 来解决。

此外,控制适配器可以更改输出 - 例如 CSS 控制适配器 将为大多数情况输出样式化的 div表格控件(登录、注册、中继器等)。

请注意,TechEd/PDC 上宣布 ASP.NET 4.0 将默认内置 CSS 控制适配器。

Stephen's list is pretty comprehensive. I'd add the following notes to it though:

Mostly it depends on the known BrowserCaps.

A 1.x Panel will render as a div in IE6+ - however in Firefox (or other "DownStream" browsers - considered DownStream because there were no details of it in the Machine.Config by default) it will render as a single cell Table - this could be resolved by supplying updated BrowserCaps for Firefox/Opera/Safari/etc, either in the Machine.Config or Web.Configs.

Also, Control Adapters can change the output - for example the CSS Control Adapters will output styled divs for most of the tabular controls (login, registration, repeaters, etc).

Note that it was announced at TechEd/PDC that ASP.NET 4.0 will have the CSS control adapters built in by default.

雨落□心尘 2024-07-20 06:49:15

这并不能直接回答您的问题,但在很多情况下,您可以将 runat="server" 添加到常规 HTML 标记以使 ASP.Net 意识到这一点。 如果您希望能够动态更改页面,但仍允许设计人员对其进行处理,这可能会让设计人员的工作变得更容易。

<div id="myDiv" runat="server"></div>
<span id="mySpan" runat="server"></span>

编辑:

我忘记提及的一件事(正如 steve_c 所指出的)是添加 runat="server" 将更改标签的 ID,这可能有点麻烦。 如果您在 CSS 中使用 ID,那么您有点运气不好,但在 JavaScript 中您可以添加类似 <%= myDiv.ClientID %> 的内容。 获取.Net 生成的 ID。

This doesn't directly answer your question, but in a lot of cases, you can add runat="server" to a regular HTML tag to make ASP.Net aware of it. That might make things easier for the designer, if you want to be able to dynamically change the page, but still allow the designer to work on it.

<div id="myDiv" runat="server"></div>
<span id="mySpan" runat="server"></span>

Edit:

One thing that I forgot to mention (as pointed out by steve_c) is that adding runat="server" will change the ID for the tag, which can be a little bit of a pain. You're kind of out of luck if you're using the ID in your CSS, but in your JavaScript you can add something like <%= myDiv.ClientID %> to get the ID that was generated by .Net.

痞味浪人 2024-07-20 06:49:15

如果您需要呈现特定标签,htmlgenericcontrol 可能会有所帮助

htmlgenericcontrol might be of help if you need to render a specific tag

巡山小妖精 2024-07-20 06:49:15
protected void CreateHeaders(List<Group_Info> group_Info)
{
    foreach (Group_Info gi in group_Info)
    {
        HtmlGenericControl groupContainer = new HtmlGenericControl("DIV");
        String lastLableID = "disp" + gi.GroupName.ToString().Replace(" ", "");
        groupContainer.ID = lastLableID;
        groupContainer.Attributes.Add("class", "content-groups");

        HtmlGenericControl groupTitle = new HtmlGenericControl("DIV");
        groupTitle.ID = lastLableID + "Sub1";
        if (gi.GroupName.Trim().Length == 0)
            groupTitle.Attributes.Add("class", "titlebar-hidden");
        else
        {
            groupTitle.Attributes.Add("class", "titlebar");
            groupTitle.InnerText = gi.GroupName.ToString().Trim();
        }

        groupContainer.Controls.Add(groupTitle);

        CreateFields(gi, ref groupContainer);

        this.pageContainer.Controls.Add(groupContainer);
    }
}
protected void CreateHeaders(List<Group_Info> group_Info)
{
    foreach (Group_Info gi in group_Info)
    {
        HtmlGenericControl groupContainer = new HtmlGenericControl("DIV");
        String lastLableID = "disp" + gi.GroupName.ToString().Replace(" ", "");
        groupContainer.ID = lastLableID;
        groupContainer.Attributes.Add("class", "content-groups");

        HtmlGenericControl groupTitle = new HtmlGenericControl("DIV");
        groupTitle.ID = lastLableID + "Sub1";
        if (gi.GroupName.Trim().Length == 0)
            groupTitle.Attributes.Add("class", "titlebar-hidden");
        else
        {
            groupTitle.Attributes.Add("class", "titlebar");
            groupTitle.InnerText = gi.GroupName.ToString().Trim();
        }

        groupContainer.Controls.Add(groupTitle);

        CreateFields(gi, ref groupContainer);

        this.pageContainer.Controls.Add(groupContainer);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文