473,406 Members | 2,387 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,406 software developers and data experts.

ASP.NET Class Files

Hey,

Soryr to post this, but im getting amasingly confused from all of the
information out there, but i was wondering if some one could help me
with these 2 questions please, because they would imporve the quality
of my code alot.

1/ Is there any way that you can edit the <headtag, because some of
my Class's have functions in there that are controled by JavaScript or
VBScript, (Address Book being a excellent example), and also i would
like to write my class's so that they can place a Link to a stylesheet
(If one exists) else jsut write a defualt style to the head (Thou i
guess a better way, might be to get it to look for the stylesheet, and
if it dont exists build a dummy one, and store it to the web server,
but still is it possible to write to the head please

2/ In a class is there any way that you can use the page that called
it without having to do something like this:

c#:
public ClassName(System.Web.UI.Page oPage)
{
oPage.Controls.Add(MyControl);
}

VB.NET:
Public Sub New(oPage as System.Web.UI.Page)
oPage.Controls.Add(MyControl)
End Sub

Instead i would like to do something like this:

C#:
public ClassName()
{
PageThatIsUsed.Controls.Add(MyControl);
}

VB.Net:
Public Sub New()
PageThatIsUsed.Controls.Add(MyControl)
End Sub

As you can see with that one, i wont ahve to get the user to specify
the page, it will default go to the page that is called.

Regards
CDove

Mar 15 '07 #1
7 1154
"Dessip" <De****@gmail.comwrote in message
news:11**********************@l75g2000hse.googlegr oups.com...
Is there any way that you can edit the <headtag
http://msdn2.microsoft.com/en-us/lib....htmlhead.aspx

C#:
public ClassName()
{
//PageThatIsUsed.Controls.Add(MyControl);
this.Controls.Add(MyControl);
}

VB.Net:
Public Sub New()
'PageThatIsUsed.Controls.Add(MyControl)
Me.Controls.Add(MyControl)
End Sub
Mar 15 '07 #2
Hey Mark,

That is excellent thank you, but the problem is i dont inherit
System.Web.UI.Page, this is in a seperate CS File, sorry i forgot to
mention that, so when i put this. or Me. it only comes up with the
functions that are in the CS Files, and not the other Page Propertys
and Functions.

Thank you for information about the head, that is exactly what im
looking for, excellent thank you.

Regards
CDove
>
C#:
public ClassName()
{
//PageThatIsUsed.Controls.Add(MyControl);
this.Controls.Add(MyControl);

}

VB.Net:
Public Sub New()
'PageThatIsUsed.Controls.Add(MyControl)
Me.Controls.Add(MyControl)
End Sub

Mar 15 '07 #3
"Dessip" <De****@gmail.comwrote in message
news:11********************@o5g2000hsb.googlegroup s.com...
That is excellent thank you, but the problem is i dont inherit
System.Web.UI.Page, this is in a seperate CS File, sorry i forgot to
mention that, so when i put this. or Me. it only comes up with the
functions that are in the CS Files, and not the other Page Propertys
and Functions.
Ah... You might be able to use Reflector for what you need - I'm not sure,
though... sorry...
Thank you for information about the head, that is exactly what im
looking for, excellent thank you.
No problem.
Mar 15 '07 #4
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:u2**************@TK2MSFTNGP03.phx.gbl...
Ah... You might be able to use Reflector for what you need - I'm not sure,
though... sorry...
Or maybe not: http://www.thescripts.com/forum/thread236981.html
Mar 15 '07 #5
Hey Mark,

Excellent thank you, after reading that thread i think i shall stick
with the way i was currently doing it, and allwoing the user to add a
refrence location for the controls that are being sent to the page,
Just would have been nicer for the user(future coder of my class) if
it automatically done it for them.

Regards
CDove

On Mar 15, 3:18 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"Mark Rae" <m...@markNOSPAMrae.comwrote in message

news:u2**************@TK2MSFTNGP03.phx.gbl...
Ah... You might be able to use Reflector for what you need - I'm not sure,
though... sorry...

Or maybe not:http://www.thescripts.com/forum/thread236981.html

Mar 15 '07 #6
"Dessip" <De****@gmail.comwrote in message
news:11**********************@p15g2000hsd.googlegr oups.com...
Excellent thank you, after reading that thread i think i shall stick
with the way i was currently doing it, and allwoing the user to add a
refrence location for the controls that are being sent to the page,
Just would have been nicer for the user(future coder of my class) if
it automatically done it for them.
In fact, that article hints at why that actually wouldn't be a very good
idea... :-)
Mar 15 '07 #7
On Mar 15, 8:22 am, "Dessip" <Des...@gmail.comwrote:
Hey,

Soryr to post this, but im getting amasingly confused from all of the
information out there, but i was wondering if some one could help me
with these 2 questions please, because they would imporve the quality
of my code alot.

1/ Is there any way that you can edit the <headtag, because some of
my Class's have functions in there that are controled by JavaScript or
VBScript, (Address Book being a excellent example), and also i would
like to write my class's so that they can place a Link to a stylesheet
(If one exists) else jsut write a defualt style to the head (Thou i
guess a better way, might be to get it to look for the stylesheet, and
if it dont exists build a dummy one, and store it to the web server,
but still is it possible to write to the head please

2/ In a class is there any way that you can use the page that called
it without having to do something like this:

c#:
public ClassName(System.Web.UI.Page oPage)
{
oPage.Controls.Add(MyControl);

}

VB.NET:
Public Sub New(oPage as System.Web.UI.Page)
oPage.Controls.Add(MyControl)
End Sub

Instead i would like to do something like this:

C#:
public ClassName()
{
PageThatIsUsed.Controls.Add(MyControl);

}

VB.Net:
Public Sub New()
PageThatIsUsed.Controls.Add(MyControl)
End Sub

As you can see with that one, i wont ahve to get the user to specify
the page, it will default go to the page that is called.

Regards
CDove
CDove,

If brevity is your issue (I got that impression, possibly
incorrectly), you can work around that with a With...End With block in
Visual Basic.

If it's not the issue, I'd recommend requiring the parameter anyway,
for a couple of reasons. The most important reason is that it creates
an explicit contract between the class and whoever instantiates it;
the class doesn't assume anything about the environment it's created
in, so that environment is free to change, and won't be broken if that
environment does change.

Further, anyone who reads the class's code will know *exactly* where
that value came from: it was provided. The class won't be *assuming*
anything about external details, or making potentially unsafe
decisions about the class that instantiated it.

Hope this helps!

Mike

Mar 15 '07 #8

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

Similar topics

3
by: Hal Vaughan | last post by:
My first Java project has gotten to the point where there are so many .java and .class files that I'd like to keep them separated so I can easily keep files straight. I have my /home/me directory...
2
by: Harold Ensle | last post by:
Has anyone ever had this problem? I have been compiling servlet files, correcting them, recompiling them and seeing the changes on the next URL request. So everything was going smoothly. Suddenly...
7
by: A_StClaire_ | last post by:
hi, I'm working on a project spanning five .cpp files. each file was used to define a class. the first has my Main and an #include for each of the other files. problem is my third file...
14
by: Mick | last post by:
I wrote a C# program that interfaces with a data vendor over the web using an API they supplied and their examples in C#. Now I have another data vendor's API and example that I want to add to...
16
by: pawel.pabich | last post by:
Hajo, I would like to have 2 my own partial classes. For example: Default.aspx.cs Default2.aspx.cs and they both will relate to Default.aspx page.
11
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with...
32
by: Matias Jansson | last post by:
I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. As I have understood it, it is more common practice to have many...
5
by: Marcin Gil | last post by:
Hi! I have the code like this (obvious things like ctor/dtor removed) typedef struct _NODE { int val; int index; } Node;
2
by: yalbizu | last post by:
#include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; const int NO_OF_STUDENTS=20; struct studentType { string studentFName; string studentLName;
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.