我如何从一个跨度改变我的自定义控件的呈现行为 [英] How Do I Change the render behavior of my custom control from being a span

查看:140
本文介绍了我如何从一个跨度改变我的自定义控件的呈现行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在写它总是呈现为HTML span元素的自定义控件。
我怎样才能改变它,例如以一个div?

When writing a custom control it always rendered as an HTML span element. How can I change it for example to a div?

推荐答案

派生自WebControl您的控制如下:

Derive your control from WebControl as follows:

public class MyCustomControl : WebControl {
    public MyCustomControl() : base(HtmlTextWriterTag.Div) {}
}

也就是说,使用基类的构造函数接受标签使用。

That is, use the base class constructor that accepts the tag to use.

这篇关于我如何从一个跨度改变我的自定义控件的呈现行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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