<ParseChildren(True), DefaultProperty("Title"), _
ToolboxData("<{0}:MyMessageControl runat=server></{0}:MyMessageControl>")> _
Public Class MyMessageControl
Inherits System.Web.UI.WebControls.WebControl
Private _MessageControl As New Panel
Public Sub New()
MyBase.New()
[Width] = WebControls.Unit.Pixel(300)
[BackColor] = System.Drawing.Color.FromArgb(&HFFFFCC)
[Title] = "タイトルを設定してください"
End Sub
<Bindable(True), Category("Appearance"), DefaultValue("")> _
Property [Title]() As String
Get
Return CType(ViewState("Title"), String)
End Get
Set(ByVal Value As String)
ViewState("Title") = Value
End Set
End Property
<PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property MessageControl() As Panel
Get
Return _MessageControl
End Get
Set(ByVal Value As Panel)
_MessageControl = Value
End Set
End Property
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
Try
If [Visible] = True Then
Dim htmlDiv1 As HtmlGenericControl = New HtmlGenericControl("DIV")
Dim htmlDiv2 As HtmlGenericControl = New HtmlGenericControl("DIV")
Dim htmlDiv3 As HtmlGenericControl = New HtmlGenericControl("DIV")
Dim htmlDiv4 As HtmlGenericControl = New HtmlGenericControl("DIV")
Dim htmlDiv5 As HtmlGenericControl = New HtmlGenericControl("DIV")
Dim uc As New UnitConverter
Dim wc As New WebColorConverter
htmlDiv1.Style.Add("border-top", "#999999 1px solid")
htmlDiv1.Style.Add("border-right", "#666666 1px solid")
htmlDiv1.Style.Add("border-left", "#666666 1px solid")
htmlDiv1.Style.Add("border-bottom", "#666666 1px solid")
htmlDiv1.Style.Add("width", uc.ConvertToString(Me.Width))
htmlDiv2.Style.Add("border-top", "#ffffff 1px solid")
htmlDiv2.Style.Add("border-right", "#999999 1px solid")
htmlDiv2.Style.Add("border-left", "#ffffff 1px solid")
htmlDiv2.Style.Add("border-bottom", "#999999 1px solid")
' タイトル領域
htmlDiv3.Style.Add("padding-top", "3px")
htmlDiv3.Style.Add("padding-right", "3px")
htmlDiv3.Style.Add("padding-left", "3px")
htmlDiv3.Style.Add("padding-bottom", "4px")
htmlDiv3.Style.Add("background-color", "#cccccc")
htmlDiv3.Style.Add("text-align", "left")
htmlDiv3.InnerText = [Title]
htmlDiv4.Style.Add("border-top", "#999999 1px solid")
htmlDiv4.Style.Add("border-right", "#cccccc 1px solid")
htmlDiv4.Style.Add("border-left", "#999999 1px solid")
htmlDiv4.Style.Add("border-bottom", "#cccccc 1px solid")
' メッセージ領域
htmlDiv5.Style.Add("padding-top", "8px")
htmlDiv5.Style.Add("padding-right", "8px")
htmlDiv5.Style.Add("padding-left", "8px")
htmlDiv5.Style.Add("padding-bottom", "8px")
htmlDiv5.Style.Add("border-top", "#666666 1px solid")
htmlDiv5.Style.Add("border-right", "#666666 1px solid")
htmlDiv5.Style.Add("border-left", "#666666 1px solid")
htmlDiv5.Style.Add("border-bottom", "#999999 1px solid")
htmlDiv5.Style.Add("background-color", wc.ConvertToString([BackColor]))
htmlDiv5.Style.Add("text-align", "left")
htmlDiv5.Controls.Add([MessageControl])
htmlDiv4.Controls.Add(htmlDiv5)
htmlDiv2.Controls.Add(htmlDiv3)
htmlDiv2.Controls.Add(htmlDiv4)
htmlDiv1.Controls.Add(htmlDiv2)
htmlDiv1.RenderControl(output)
End If
Catch ex As Exception
output.Write(ex.Message)
End Try
End Sub
End Class
|