473,379 Members | 1,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

What is the most efficient way to access common fcts on asp.net pages when using user controls?

What is the most efficient way to code asp.net pages when you break your
page up into user controls?

For example: If you have a page with a header (control .ascx), body, and
footer (control .ascx) for a given page and you need to access functions
within a class (bizUtil say) should you declare the bizUtil object on the
header and footer in both the aspx and aspx.vb pages? That's FOUR
references!

This seems bloatful (my new word).

Just wondering,

Brent
Nov 18 '05 #1
3 1278
Hi.

Two ways:
You can create a separate class somewhere in your project
with static method(s) that you need if this class does
not need initialization (I'm not sure what "statis"
stands for in VB). Than use it in your user control: (C#)
classNamespace.className.staticMethod(someParamete r);

Second:
Create a base class(es) for your user control(s). Derive
this base from System.Web.UI.UserControl. Then place all
methods your "child" controls might need inside of this
base class. Then derive all or some of your user controls
from this base control class and you're done. Just call
those methods right from "child" controls. Very neat,
efficient, hassle free and elegant approach :)

Regards.
-----Original Message-----
What is the most efficient way to code asp.net pages when you break yourpage up into user controls?

For example: If you have a page with a header (control .ascx), body, andfooter (control .ascx) for a given page and you need to access functionswithin a class (bizUtil say) should you declare the bizUtil object on theheader and footer in both the aspx and aspx.vb pages? That's FOURreferences!

This seems bloatful (my new word).

Just wondering,

Brent
.

Nov 18 '05 #2
Thanks so much for the help. I don't have a clue how to do either of these,
but now at least i know what to go read up on. Hard to believe i've been
doing this for over 10 years : )

Thanks,

Brent
"Kikoz" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
Hi.

Two ways:
You can create a separate class somewhere in your project
with static method(s) that you need if this class does
not need initialization (I'm not sure what "statis"
stands for in VB). Than use it in your user control: (C#)
classNamespace.className.staticMethod(someParamete r);

Second:
Create a base class(es) for your user control(s). Derive
this base from System.Web.UI.UserControl. Then place all
methods your "child" controls might need inside of this
base class. Then derive all or some of your user controls
from this base control class and you're done. Just call
those methods right from "child" controls. Very neat,
efficient, hassle free and elegant approach :)

Regards.
-----Original Message-----
What is the most efficient way to code asp.net pages

when you break your
page up into user controls?

For example: If you have a page with a header

(control .ascx), body, and
footer (control .ascx) for a given page and you need to

access functions
within a class (bizUtil say) should you declare the

bizUtil object on the
header and footer in both the aspx and aspx.vb pages?

That's FOUR
references!

This seems bloatful (my new word).

Just wondering,

Brent
.

Nov 18 '05 #3
Hey it works!

I did it the first way with a static (notinheritable) class with shared
functions. The other thing i had to do was to stub out a private
constructor:

Public NotInheritable Class BizGUI

Private Sub New()
'Seal this class off. Throws a compile error if consumer tries to
instantiate.
End Sub

Public Shared Function backToTop() As String
Return "<a href='#top' class=back>back&nbsp;to&nbsp;top</a><BR
clear=all><BR>"
End Function

Public Shared Function vSpacer(ByVal NumPixelsIN As Int16) As String
Return "<img src='./images/blank.gif' width=1 height=" &
NumPixelsIN.ToString & " border=0>"
End Function

End Class

Thanks!

Brent
"Kikoz" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
Hi.

Two ways:
You can create a separate class somewhere in your project
with static method(s) that you need if this class does
not need initialization (I'm not sure what "statis"
stands for in VB). Than use it in your user control: (C#)
classNamespace.className.staticMethod(someParamete r);

Second:
Create a base class(es) for your user control(s). Derive
this base from System.Web.UI.UserControl. Then place all
methods your "child" controls might need inside of this
base class. Then derive all or some of your user controls
from this base control class and you're done. Just call
those methods right from "child" controls. Very neat,
efficient, hassle free and elegant approach :)

Regards.
-----Original Message-----
What is the most efficient way to code asp.net pages

when you break your
page up into user controls?

For example: If you have a page with a header

(control .ascx), body, and
footer (control .ascx) for a given page and you need to

access functions
within a class (bizUtil say) should you declare the

bizUtil object on the
header and footer in both the aspx and aspx.vb pages?

That's FOUR
references!

This seems bloatful (my new word).

Just wondering,

Brent
.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
1
by: yma | last post by:
Hi, I tried to use a listbox to display a column in MS Access 2000 nwind.mdb by using ole DataAdapter, Connection and dataset controls. But I got "It is already opened exclusively by another...
3
by: qwerty | last post by:
I´m new to ASP.Net. My workmate has some experience with it. He claimed that in ASP.Net working with frames is much simpler than it was ASP. I asked explanation but he couldn't give me such. (a...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
3
by: Mr Newbie | last post by:
I am messing around with Web User Controls at present and (think) I have discovered the following. 1.) The identifier for the control in the code behind must match the ID for the control on the...
3
by: clintonG | last post by:
Why don't we see more WebParts being used on the web? SharePoint gets all the fun? And what are the prevailing opinions be they what they may about the use of WebParts rather than WPF when the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.