Well, I am trying to make a control that writes an html table with a title and a small body with a message. I want to include a link in the table's title so that it can make the body's message disappear or appear (Open / Close).
So, I have made the .vb file that successfully makes a new class that writes the html table. The file isn't completed yet but works just fine up to a point. It has 3 properties. The one defines the title, the other defines the state of the message (closed or opened) and the other assigns an integer ID so that I can identify the server controls contained in one web control from another (the one will have controls with IDs ending to its specified integer and the other will have IDs ending to its own specified integer).
Also, I have successfully included the .dll from the BIN directory to my test aspx page and no problem. Some more specifications: In order to make the message disappear or re-appear, I wrapped it up in a <asp:placeholder> tag and I play with its "visible" property.
The body message is just the Literal Controls or Controls that exists between my custom tag. I just add these control to the PlaceHolder I mentioned.
So, here's the real problem: I included the placeholder and the linkbutton to the document but I don't know how to relate the click of the linkbutton to the method/event of the .vb file that makes the message appear or disappear. If you find any other errors in the following document, please go ahead and tell me. Thx 2 any1 who can make that damn linkbutton work!
Here are the 2 docs (the .vb and the .aspx-the apsx includes the control from another included file):
-----------------------------------VB FILE----------------------------------------------
' Displayor.vb
'
Imports System
Imports System.Web
Imports System.Web.UI
Imports Microsoft.VisualBasic
Namespace TPControls
Public Class Displayor: Inherits Control
'Public Delegate Sub EventHandler(sender As Object, e As EventArgs)
'Public Event ChangeStatus As EventHandler
Public Opened As Boolean = True
Public strTitle As String = "Undefined main title"
Public cID As Integer
Public WithEvents OpenCloseLink As System.Web.UI.WebControls.Button
Protected Overrides Sub Render(out As HtmlTextWriter)
'Initialize WebControls
'Linkbutton
OpenCloseLink = New System.Web.UI.WebControls.Button()
AddHandler OpenCloseLink.Click, AddressOf Me.ChangeSatus
OpenCloseLink.ID = "MenuLink" & cID
OpenCloseLink.Style("color") = "DimGray"
OpenCloseLink.Style("font-size") = "13px"
OpenCloseLink.CommandName = "ChangeOpened"
If Opened Then
OpenCloseLink.Text = "Close"
OpenCloseLink.CommandArgument = "False"
Else
OpenCloseLink.Text = "Open"
OpenCloseLink.CommandArgument = "True"
End If
'PlaceHolder
Dim BodyHolder As New System.Web.UI.WebControls.PlaceHolder()
BodyHolder.ID = "MenuBodyHolder" & cID
Dim CControl
For Each CControl In Controls
BodyHolder.Controls.Add(CControl)
Next
If Opened Then
BodyHolder.visible = True
Else
BodyHolder.visible = False
End If
' ENDING intializing webcontrols
out.Write("<center><table cellpadding='0' cellspacing='0' width='90%' style='border: 1px solid #D3D3D3'><tr><td Width='100%' style='font-size:15px; color:black;background-color:#A9A9A9'>")
out.Write("<table cellpadding='0' cellspacing='0' width='100%'><tr><td width='100%' style='font-size:15px; color:black;background-color:#A9A9A9'>")
out.Write(strTitle)
out.Write("</td><td>")
OpenCloseLink.RenderControl(out)
out.Write("</td></tr></table></td></tr>")
out.Write("<tr><td width='100%' height='100%' style='font-size:12px;color:white; background-color: #696969'>")
BodyHolder.RenderControl(out)
out.Write(Opened)
out.Write("</td></tr></table></center>")
End Sub
'Sub OpenCloseLink_Clicked(sender As Object, e As EventArgs) Handles OpenCloseLink.Click
'If Opened Then
'Opened = False
'Else
'Opened = True
'End If
'Me.FindControl("MenuBodyHolder" & cID).visible = Opened
'End Sub
'Protected Overridable Sub OnChangeStatus(e As EventArgs)
'
'End Sub
Sub ChangeSatus(sender As Object, e As EventArgs)
Me.FindControl("MenuBodyHolder" & cID).visible = False
Me.FindControl("BodyHolder").visible = False
End Sub
End Class
End Namespace
-----------------------------------------------------------------------------------------
------------------------------------ASPX file (part of it)---------------------------------
<!-- Small part containing the custom control -->
<TP:Displayor runat="server" strTitle="Temporary object" cID=1><asp:placeholder ID="MenuRealBody1" runat="server">
Hi 2 all of you!
</asp:placeholder></TP:Displayor>
-----------------------------------------------------------------------------------------