ASP.NET Tutorial/Custom Controls/Themes — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:00, 26 мая 2010
Disabling theme support on a control property (C#)
<source lang="csharp">
using System; using System.Collections.Generic; using System.ruponentModel; using System.Text; using System.Web.UI; using System.Web.UI.WebControls; namespace WebControlLibrary1 {
[DefaultProperty("Text")] [ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")] public class WebCustomControl1 : WebControl { private string text; [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Themeable(false)] public string Text { get { return text; } set { text = value; } } protected override void Render(HtmlTextWriter output) { output.RenderBeginTag(HtmlTextWriterTag.Div); output.AddAttribute(HtmlTextWriterAttribute.Type, "text"); output.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID); output.AddAttribute(HtmlTextWriterAttribute.Name, this.ClientID); output.AddAttribute(HtmlTextWriterAttribute.Value, this.Text); output.RenderBeginTag(HtmlTextWriterTag.Input); output.RenderEndTag(); output.RenderEndTag(); } }
}</source>
Disabling theme support on a control property (VB)
<source lang="csharp">
Imports System.ruponentModel Imports System.Web.UI <DefaultProperty("Text"), _
ToolboxData("<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>")>
Public Class WebCustomControl1
Inherits System.Web.UI.WebControls.WebControl Dim _text As String <Bindable(True), Category("Appearance"), Themeable(False), DefaultValue("")> _ Property [Text]() As String Get Return _text End Get Set(ByVal Value As String) _text = Value End Set End Property Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter) output.RenderBeginTag(HtmlTextWriterTag.Div) output.AddAttribute(HtmlTextWriterAttribute.Type, "text") output.AddAttribute(HtmlTextWriterAttribute.Id, Me.ClientID) output.AddAttribute(HtmlTextWriterAttribute.Name, Me.ClientID) output.AddAttribute(HtmlTextWriterAttribute.Value, Me.Text) output.RenderBeginTag(HtmlTextWriterTag.Input) output.RenderEndTag() output.RenderEndTag() End Sub
End Class</source>