by . .
Feedback
|
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days):
34374/
44
|
|
|
The Class |
The Class
The designer class, is not part of the Control or Webcontrol
classes and therefore is slightly different in terms of implementation.
The class that contains the functionality is the
System.Web.UI.Design.ControlDesigner class which provides several functions,
which aid in providing the design-time HTML.
If you are using VS.NET, remember to add a reference to System.Design.dll
so that you can see this class (as it is not contained within System.Web.dll).
Current Code
The code that will be used for the rest of this article, will be the
Multi-Highlighter custom control and we will be improving it upon.
Public
Class
DesignerSample
Inherits
System.Web.UI.WebControls.WebControl
Implements
IPostBackEventHandler
Private _Text()
As
String
= {""}
<Category("Misc"), _
Description("Specifies the text to be displayed."), _
Browsable(True)>
_
Public
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)
Dim
i
output.AddAttribute("border", "1")
output.AddStyleAttribute("cursor", "hand")
output.AddStyleAttribute("border-width", "1")
output.AddStyleAttribute("border-color", "#000000")
output.RenderBeginTag("table")
For
i = 0 To
Text.GetUpperBound(0)
output.AddAttribute("onClick", Page.GetPostBackEventReference(Me,
i))
If
ViewState(ID & i) = 1
Then
output.AddAttribute("bgcolor", "#85FF72")
Else
output.AddAttribute("bgcolor", "#FFFFFF")
End
If
output.RenderBeginTag("tr")
output.RenderBeginTag("td")
output.AddAttribute("face", "Arial")
output.AddAttribute("size", "2")
output.RenderBeginTag("font")
output.Write(Text(i))
output.RenderEndTag()
output.RenderEndTag()
output.RenderEndTag()
Next
output.RenderEndTag()
End
Sub
Public
Sub
PostBackEvent(ByVal
eventargs As
String)
Implements
IPostBackEventHandler.RaisePostBackEvent
If
ViewState(ID & eventargs) = 1
Then
ViewState(ID & eventargs) = 0
Else
ViewState(ID & eventargs) = 1
End
If
End
Sub
End
Class |
You may see in the code that the
Text field is now exposed as a property with design-time attributes and
_Text is initialized.
|
|
|
User Comments
No comments posted yet.
|
Product Spotlight
|
|