如何在asp.net中实现嵌入自定义标签?
我找到了这个例子:
<telerik:RadDatePicker
ID="RadDatePicker1"
runat="server">
<DateInput Width="100%"></DateInput>
<Calendar
CellAlign="Center"
CellVAlign="Middle"
DayNameFormat="FirstLetter"
FirstDayOfWeek="Default"
MonthLayout="Layout_7columns_x_6rows"
Orientation="RenderInRows"
TitleAlign="Center"
UseColumnHeadersAsSelectors="False"
ShowRowHeaders="False">
</Calendar>
<DatePopupButton
CssClass="radPopupImage_Default"
BorderColor="#D0E1F2"
BorderStyle="Solid"
BorderWidth="1px" />
我的假设是,RadDatePicker 内部有一个 DateInput 对象、Calendar 对象和 DatePopupButton 对象。
我想要拥有自己的自定义控件,允许访问内部对象,例如
<jonno:textbox id="txt1" runat="server"><FieldConfig fieldName="Input1"/></jonno:textbox>
理想情况下,我不希望 FieldConfig 类成为可视类,但如果是的话也没关系。
我怎样才能实现这个目标?
I found this example:
<telerik:RadDatePicker
ID="RadDatePicker1"
runat="server">
<DateInput Width="100%"></DateInput>
<Calendar
CellAlign="Center"
CellVAlign="Middle"
DayNameFormat="FirstLetter"
FirstDayOfWeek="Default"
MonthLayout="Layout_7columns_x_6rows"
Orientation="RenderInRows"
TitleAlign="Center"
UseColumnHeadersAsSelectors="False"
ShowRowHeaders="False">
</Calendar>
<DatePopupButton
CssClass="radPopupImage_Default"
BorderColor="#D0E1F2"
BorderStyle="Solid"
BorderWidth="1px" />
My assumption is that inside the RadDatePicker there is a DateInput object, Calendar Object and DatePopupButton object.
I would like to have my own custom control that allows access to an inner object e.g.
<jonno:textbox id="txt1" runat="server"><FieldConfig fieldName="Input1"/></jonno:textbox>
Ideally I don't want the FieldConfig class to be a visual class but it's ok if it is.
How can I achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嵌入的自定义标签是控件的属性。要在标记中设置它们,您需要使用以下属性来装饰您的控件和属性:
我使用的控件中的示例执行类似操作:
在 msdn 上查找属性以了解有关内容他们确实这么做了。上面的内容应该可以满足您的需要。
然后,在标记中,我可以简单地分配两个视图:
唯一的区别是我的属性仍然是 WebControl,并带有更多子控件。不过,只要你正确设置你的属性,这就不重要了。
门诺
The embedded custom tags are properties of your control. To enable setting them in markup, you need to decorate your control and properties with the following attributes:
Example from a control I use that does something similar:
Look the attributes up on msdn to read up on what they do exactly. The above should do what you need it to do though.
In markup I can then simply assign the two views:
THe only difference is that my properties are still WebControls and take more child controls. It shouldn´t matter though, as long as you set your attributes right.
Menno