This documentation is archived and is not being maintained.
ControlDesigner.IsDirty Property
.NET Framework 1.1
Gets or sets a value indicating whether the Web server control has been marked as changed.
[Visual Basic] Public Property IsDirty As Boolean [C#] public bool IsDirty {get; set;} [C++] public: __property bool get_IsDirty(); public: __property void set_IsDirty(bool); [JScript] public function get IsDirty() : Boolean; public function set IsDirty(Boolean);
Property Value
true if the Web server control has been changed since it was last saved or loaded; otherwise, false.
Example
[Visual Basic, C#, C++] The following code example contains a custom toggleTextSize method that sets the IsDirty property to true when the method is called.
[Visual Basic] Imports System Imports System.Web.UI Imports System.Web.UI.Design Imports System.Web.UI.WebControls Imports System.ComponentModel Imports System.ComponentModel.Design Imports Microsoft.VisualBasic Namespace Examples.AspNet ' This control designer offers designer verb menu commands ' that can alter the design time html provided for the ' System.Web.UI.Control this designer supports. Public Class TextSizeWebControlDesigner Inherits System.Web.UI.Design.ControlDesigner ' Whether to display the html of the associated ' control using a large heading text size. Private LargeText As Boolean Private dvc As DesignerVerbCollection = Nothing Public Sub New() LargeText = True End Sub ' Provides a menu command to toggle the text size. Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection Get Dim verbReduce As DesignerVerb = _ New DesignerVerb("Reduce text size", New EventHandler(AddressOf Me.toggleTextSize)) Dim verbEnlarge As DesignerVerb = _ New DesignerVerb("Enlarge text size", New EventHandler(AddressOf Me.toggleTextSize)) If dvc Is Nothing Then dvc = New DesignerVerbCollection() dvc.Add(verbReduce) dvc.Add(verbEnlarge) ElseIf (dvc.Contains(verbEnlarge) = False) Then dvc.Add(verbEnlarge) ElseIf (dvc.Contains(verbReduce) = False) Then dvc.Add(verbReduce) End If If LargeText Then dvc.Remove(verbEnlarge) Else dvc.Remove(verbReduce) End If Return dvc End Get End Property ' Returns the html to use to represent the control at design time. Public Overrides Function GetDesignTimeHtml() As String Dim html As String = MyBase.GetDesignTimeHtml() If LargeText Then Return "<H1>" + html + "</H1>" Else Return "<H3>" + html + "</H3>" End If End Function ' Event handler to toggle whether the html receives a large or ' small size heading markup tag. Private Sub ToggleTextSize(ByVal sender As Object, ByVal e As EventArgs) If LargeText Then LargeText = False Else LargeText = True End If Me.IsDirty = True Me.UpdateDesignTimeHtml() End Sub End Class ' Simple text Web control renders a text string. ' This control is associated with the TextSizeWebControlDesigner. <DesignerAttribute(GetType(TextSizeWebControlDesigner), GetType(IDesigner))> _ Public Class TextControl Inherits System.Web.UI.WebControls.WebControl Private [text_] As String <Bindable(True), Category("Appearance"), DefaultValue("")> _ Public Property [Text]() As String Get Dim o As Object = ViewState("Text") Return IIf(o Is Nothing, String.Empty, CStr(o)) End Get Set If HasControls() Then Controls.Clear() End If ViewState("Text") = value End Set End Property Public Sub New() [text_] = "Test phrase" End Sub Protected Overrides Sub RenderContents(ByVal output As HtmlTextWriter) output.Write([Text]) End Sub End Class [C#] using System; using System.Web.UI; using System.Web.UI.Design; using System.Web.UI.WebControls; using System.ComponentModel; using System.ComponentModel.Design; namespace Examples.AspNet { // This control designer offers designer verb menu commands // that can alter the design time html provided for the // System.Web.UI.Control this designer supports. public class TextSizeWebControlDesigner : System.Web.UI.Design.ControlDesigner { // Whether to display the html of the associated // control using a large heading text size. private bool LargeText; private DesignerVerbCollection dvc; public TextSizeWebControlDesigner() : base() { LargeText = true; } // Provides a menu command to toggle the text size. public override System.ComponentModel.Design.DesignerVerbCollection Verbs { get { DesignerVerb verbReduce = new DesignerVerb("Reduce text size", new EventHandler(this.ToggleTextSize)); DesignerVerb verbEnlarge = new DesignerVerb("Enlarge text size", new EventHandler(this.ToggleTextSize)); if (dvc == null){ dvc = new DesignerVerbCollection(); dvc.Add(verbReduce); dvc.Add(verbEnlarge); } else if (dvc.Contains(verbEnlarge) == false){ dvc.Add(verbEnlarge); } else if (dvc.Contains(verbReduce) == false){ dvc.Add(verbReduce); } if( LargeText ) dvc.Remove(verbEnlarge); else dvc.Remove(verbReduce); return dvc; } } // Returns the html to use to represent the control at design time. public override string GetDesignTimeHtml() { string html = base.GetDesignTimeHtml(); if( LargeText ) return "<H1>"+html+"</H1>"; else return "<H3>"+html+"</H3>"; } // Event handler to toggle whether the html receives a large or // small size heading markup tag. private void ToggleTextSize(object sender, EventArgs e) { if( LargeText ) LargeText = false; else LargeText = true; this.IsDirty = true; this.UpdateDesignTimeHtml(); } } // Simple text Web control renders a text string. // This control is associated with the TextSizeWebControlDesigner. [DesignerAttribute(typeof(TextSizeWebControlDesigner), typeof(IDesigner))] public class TextControl : System.Web.UI.WebControls.WebControl { [Bindable(true), Category("Appearance"), DefaultValue("")] public string Text { get { object o = ViewState["Text"]; return((o == null) ? String.Empty : (string)o); } set { if (HasControls()) { Controls.Clear(); } ViewState["Text"] = value; } } public TextControl() { Text = "Test phrase"; } protected override void RenderContents(HtmlTextWriter output) { output.Write(Text); } } } [C++] #using <mscorlib.dll> #using <System.dll> #using <System.Web.dll> #using <System.Design.dll> using namespace System; using namespace System::Web::UI; using namespace System::Web::UI::Design; using namespace System::Web::UI::WebControls; using namespace System::ComponentModel; using namespace System::ComponentModel::Design; // This control designer offers designer verb menu commands // that can alter the design time html provided for the // System::Web::UI::Control this designer supports. public __gc class TextSizeWebControlDesigner : public ControlDesigner { // Whether to display the html of the associated // control using a large heading text size. private: bool LargeText; public: TextSizeWebControlDesigner() : ControlDesigner() { LargeText = true; } // Provides a menu command to toggle the text size. public: __property System::ComponentModel::Design::DesignerVerbCollection* get_Verbs() { DesignerVerbCollection* dvc = new DesignerVerbCollection(); if (LargeText) dvc->Add(new DesignerVerb(S"Reduce text size", new EventHandler(this, &TextSizeWebControlDesigner::ToggleTextSize))); else dvc->Add(new DesignerVerb(S"Enlarge text size", new EventHandler(this, &TextSizeWebControlDesigner::ToggleTextSize))); return dvc; } // Returns the html to use to represent the control at design time. public: String* GetDesignTimeHtml() { String* html = __super::GetDesignTimeHtml(); if (LargeText) return String::Concat(S"<H1> ", html, S"</H1>"); else return String::Concat(S"<H3> ", html, S"</H3>"); } // Event handler to toggle whether the html receives a large or // small size heading markup tag. private: void ToggleTextSize(Object* /*sender*/, EventArgs* /*e*/) { if (LargeText) LargeText = false; else LargeText = true; this->IsDirty = true; this->UpdateDesignTimeHtml(); } }; // Simple text Web control renders a text string. // This control is associated with the TextSizeWebControlDesigner. [DesignerAttribute(__typeof(TextSizeWebControlDesigner), __typeof(IDesigner))] public __gc class TextControl : public WebControl { private: String* text; public: [Bindable(true), Category(S"Appearance"), DefaultValue(S"")] __property String* get_Text() { return text; } __property void set_Text(String* value) { text = value; } TextControl() { text = S"Test phrase"; } protected: void Render(HtmlTextWriter* output) { output->Write(Text); } };
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
.NET Framework Security:
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries From Partially Trusted Code
See Also
ControlDesigner Class | ControlDesigner Members | System.Web.UI.Design Namespace
Show: