Help with Web Custom Control

S

Simon Harris

Hi All,

I am trying to create a web custom control to handle the banner and footer
areas of our website.

Our site is, in the main ASP/VBScript driven, making heavy use of include
files.

I have two problems/queries:

1) Can I include the content of an ASP file in my control? (You can see
where I have attempted this below with response.writefile - Which VS want
happy with, told me that response was not delcared!)
2) Is my code at all right below? e.g. Am I setting the value of SB in the
right place, such that calling BopDotComHeader.Text will return the value
of
SB?

Thanks,
Simon.

-----------------

Imports System.ComponentModel
Imports System.Web.UI
Imports System.text
<DefaultProperty("Text"), ToolboxData("<{0}:BopDotComHeader
runat=server></{0}:BopDotComHeader>")> Public Class BopDotComHeader
Inherits System.Web.UI.WebControls.WebControl
<Bindable(True), Category("Appearance"), DefaultValue("")> Property
[Text]() As String
Get
Return SB
End Get
Set(ByVal Value As String)
Strtext = Value
End Set
End Property

Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
Dim SB As New StringBuilder
SB.Append("<BASEFONT FACE=ARIAL SIZE=2>")
SB.Append("<A NAME=TOP>")
SB.Append("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>")
SB.Append("<TR>")
SB.Append("<TD WIDTH=100 VALIGN=TOP>")
SB.Append(Response.WriteFile("/template/menu.asp"))
SB.Append("</TD><TD VALIGN=TOP>")
SB.Append(Response.WriteFile("/template/menutop.asp"))
SB.Append("<IMG SRC=/graphics/blank.gif WIDTH=1 HEIGHT=5 BORDER=0
ALT=>")
SB.Append("<CENTER>")
SB.Append("<TABLE WIDTH=540 BORDER=0 CELLPADDING=1 CELLSPACING=3>")
SB.Append("<TR>")
SB.Append("<TD VALIGN=TOP>")
output.Write(SB)
End Sub
End Class
 
L

Lucas Tam

Hi All,

I am trying to create a web custom control to handle the banner and
footer areas of our website.

Our site is, in the main ASP/VBScript driven, making heavy use of
include files.

I have two problems/queries:

1) Can I include the content of an ASP file in my control? (You can
see where I have attempted this below with response.writefile - Which
VS want happy with, told me that response was not delcared!)

Since the web control maybe a separate class, it might not have access
to the httpcontext.

So prefix response.write with httpcontext.current.response.write.

No, you can't include context from another ASP or ASP.NET file - the web
control has to generate all the output data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top