[thelist] vb.net: using subroutines within user controls - .ascx

Peter Brunone (EasyListBox.com) peter at easylistbox.com
Mon Oct 11 19:53:18 CDT 2004


Hi Casey,

	Sorry; I would have sent my reply sooner, but I had an
unexpected kicking (yes, actual physical kicking, albeit unintentional)
of my workstation which resulted in a reboot.  Hilarity ensued.  Anyhoo,
I'll start by answering your questions to my other reply with the same
subject line:

> What's a literal control?

<asp:Literal id="whatever" runat="server" />

Set the Text property to whatever string you were going to output with
Response.Write.

Re. user control definitions:
> Ummm, what?

	There are two steps involved if you want to put a user control
in your page.  The first is the tag definition at the top of the page:

<%@ Register TagPrefix="CrookstonControls" TagName="MyHeader"
Src="theHeader.ascx" %>

	Then there's the actual tag wherever you want the control to
appear:

<CrookstonControls:MyHeader id="theHeaderID" runat="server" />

	Now, inside your control, if you want to show some text, your
ascx file might look like this:

<%@ Control Language="VB" %>
<script runat="server">

' Here's a random public field that you can set from the page
Public sPageName As String = ""

Sub Page_Load(Src As Object, E As EventArgs)
	myLiteral.Text = sPageName
End Sub

</script>
This is the header text. <br />
This header is the page called <asp:Literal id="myLiteral"
runat="server" />


	You might have a lot more HTML formatting, etc. but that's the
basic idea.  Now, to access that public field on the control, you would
go to the appropriate place in the script of the parent page and say
something like

theHeaderID.sPageName = "somestringorvariable"

Does that start to make sense?

Peter

-----Original Message-----
From: thelist-bounces at lists.evolt.org On Behalf Of Casey Crookston
Sent: Monday, October 11, 2004 5:47 PM
To: Casey Crookston; thelist at lists.evolt.org
Subject: Re: [thelist] vb.net: using subroutines within user controls -
.ascx


Okay,  I'll make this as simple as I can think to make it.  I'm trying
to build a dynamic template site. On every page (default.aspx,
about.aspx,
contact.aspx) etc, I don't want to include the same HTML for the header
over and over and over again, so I took out the basic header that gets
re-used on every page and stuck in into a seperate file, called
HEADER.(i'm not sure of the best extension to use yet...)

Now, within HEADER.ascx/aspx/inc, there is a little bit of dynamic
content, nothing serious.  I'd like to put everthing in the HEADER file
inside a subroutine (called HEADER), so that on the main pages
(contact.aspx, about.apsx, etc) all I have to do is CALL HEADER.

Does that make sense?

So, again, this was such a simple task in classic asp.  Not so simple
ASP.NET, i guess?

Thank you!!!

Casey

P.S.  Please assume I know NOTHING when replying to this message!!



-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 




More information about the thelist mailing list