Passing values from an ASPX page to a User Control

Contributed by
Rating: 3 stars3 stars3 stars3 stars3 stars / 32
July 09, 2001
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Passing Variables from User Controls to ASP.NET pages

server-side includes to maintain a consistent look across a website is a common way I've found to be useful. ASP+ has introduced pagelets,  these pages are separate files or webpages that contain certain information you want displayed across several webpages. The nice thing about pagelet is they are very similar to server-side include files.

Both file types allow to have the code in one file and using "DIRECTIVES" to call that page across several files. I've used server-side include files to maintain a similar look and feel for many of my webpages on ASPFree.com. I used this method to dynamically pass a TitleBarDemo variable that gets set on every page. Pagelets can also contain logic code that can greatly increase the power of what they perform.

Pagelet(User Control) Code

<script language="VB" runat=server>
'Declare a public variable that can be set
Public TitleOfDemo as String

</script>
<HTML>
    <head>
                <title><% =TitleOfDemo %></title>
    </head>
<body>
</body>
</html>

ASP+ page code

'Registering the a pagelet (user control) file
'This gets listed at the top of the .aspx page

<%@ Register TagPrefix="ListFirst" TagName="ListSecond" Src="pagelet.aspc" %>

'Method of having the pagelet file executed
'Setting the TitleOfDemo variable to a value.

<ListFirst:ListSecond TitleOfDemo="ASPFree, this would show in the title bar!" runat="server"/>

 

blog comments powered by Disqus
ASP.NET CODE ARTICLES

- How to Use the ListBox Control in ASP.NET 2.0
- How to Load XML Documents in ASP.NET 2.0
- DataGrid Code
- ASP.NET Guestbook
- User Controls and Client Side Scripting
- ASP.NET Programming with Microsoft's AS...
- ASP.NET Basics (part 3): Hard Choices
- ASP.NET Basics (part 2): Not My Type
- ASP.NET Basics (part 1): Nothing But .Net
- Directory Tree Browser
- How to get the confirmation of Yes/No from a...
- Complete example using custom errors and wri...
- Paging Certain # records per page .NET style
- General Methods of formatting and Subtractin...
- .NET LinkButton web control

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials