Connecting Tech Pros Worldwide Forums | Help | Site Map

Help with Web Custom Control

Simon Harris
Guest
 
Posts: n/a
#1: Nov 19 '05
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


--
I am using the free version of SPAMfighter for private users.
It has removed 2036 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!


Lucas Tam
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Help with Web Custom Control


"Simon Harris" <too-much-spam@makes-you-fat.com> wrote in
news:eNlf#5PRFHA.3356@TK2MSFTNGP12.phx.gbl:
[color=blue]
> 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!)[/color]

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.





--
Lucas Tam (REMOVEnntp@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Closed Thread