By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,220 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,220 IT Pros & Developers. It's quick & easy.

referencing aspx pages in a class library

P: n/a
Hi all,

I try to reference several pages from a class (ideally located in a class
library). But no namespace is available to do this.

Does anybody have an idea how to do this?

Thanks for your help,

Ugo
Jul 18 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Ugo,

You may want to pass the references to the pages to your class explicitly.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Ugo Van Noorbeeck" <Va**********@guidance.bewrote in message
news:Oh**************@TK2MSFTNGP04.phx.gbl...
Hi all,

I try to reference several pages from a class (ideally located in a class
library). But no namespace is available to do this.

Does anybody have an idea how to do this?

Thanks for your help,

Ugo

Jul 18 '06 #2

P: n/a
Hi all,
>
I try to reference several pages from a class (ideally located in a class
library). But no namespace is available to do this.

Does anybody have an idea how to do this?

Thanks for your help,

Ugo
What are you trying to do? You can't access them as you can with
winform-windows, where you can read values from hidden windows.
With webforms (asp.net) all page-values are gone as soon as the request
has finished processing.

You *can* get at the current Request or Session, using
System.Web.HttpContext.Current.Request (or .Session).
You will need a project-reference to System.Web.dll for this.
Hans Kesting
Jul 18 '06 #3

P: n/a
Hello,

In fact I want to be able to alter my page(s) with a "main controller" (the
class in the class library). I have several pages that differs only by one
textbox or so. And instead of creating new pages, I made a few "pattern
pages" in which I only hide/modify some controls depending on the page to
load. (I don't think Master page can help).
So, in the page_load (or just after) I call the method in the controller
class to make the adjustments. I pass the calling page as an argument but in
the code of the method this is a generic System.Web.UI.Page and I need to
cast it in the right "pattern page" type to access the controls.
There is where I need to reference the pages.

I hope it is a bit clearer.

Many thaks,

Ugo

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com...
>Hi all,

I try to reference several pages from a class (ideally located in a class
library). But no namespace is available to do this.

Does anybody have an idea how to do this?

Thanks for your help,

Ugo

What are you trying to do? You can't access them as you can with
winform-windows, where you can read values from hidden windows.
With webforms (asp.net) all page-values are gone as soon as the request
has finished processing.

You *can* get at the current Request or Session, using
System.Web.HttpContext.Current.Request (or .Session).
You will need a project-reference to System.Web.dll for this.
Hans Kesting


Jul 18 '06 #4

P: n/a
Ugo,

You can always get the type name from the passed "page" parameter as

page.GetType().ToString();
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Ugo Van Noorbeeck" <Va**********@guidance.bewrote in message
news:uV**************@TK2MSFTNGP05.phx.gbl...
Hello,

In fact I want to be able to alter my page(s) with a "main controller"
(the class in the class library). I have several pages that differs only
by one textbox or so. And instead of creating new pages, I made a few
"pattern pages" in which I only hide/modify some controls depending on the
page to load. (I don't think Master page can help).
So, in the page_load (or just after) I call the method in the controller
class to make the adjustments. I pass the calling page as an argument but
in the code of the method this is a generic System.Web.UI.Page and I need
to cast it in the right "pattern page" type to access the controls.
There is where I need to reference the pages.

I hope it is a bit clearer.

Many thaks,

Ugo

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com...
>>Hi all,

I try to reference several pages from a class (ideally located in a
class library). But no namespace is available to do this.

Does anybody have an idea how to do this?

Thanks for your help,

Ugo

What are you trying to do? You can't access them as you can with
winform-windows, where you can read values from hidden windows.
With webforms (asp.net) all page-values are gone as soon as the request
has finished processing.

You *can* get at the current Request or Session, using
System.Web.HttpContext.Current.Request (or .Session).
You will need a project-reference to System.Web.dll for this.
Hans Kesting



Jul 18 '06 #5

P: n/a
Yes, that's right but after, I have to dynamically cast the page into this
retrieved type. How can I do that? And how can the compiler let me call,
let's say: textbox1.enbled = false; onto a type that isn't known at compile
time?

One precision, I work in C#. If it is possible in VB that would be terrific!

Ugo
"Eliyahu Goldin" <re*************@monarchmed.comwrote in message
news:Oh**************@TK2MSFTNGP03.phx.gbl...
Ugo,

You can always get the type name from the passed "page" parameter as

page.GetType().ToString();
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Ugo Van Noorbeeck" <Va**********@guidance.bewrote in message
news:uV**************@TK2MSFTNGP05.phx.gbl...
>Hello,

In fact I want to be able to alter my page(s) with a "main controller"
(the class in the class library). I have several pages that differs only
by one textbox or so. And instead of creating new pages, I made a few
"pattern pages" in which I only hide/modify some controls depending on
the page to load. (I don't think Master page can help).
So, in the page_load (or just after) I call the method in the controller
class to make the adjustments. I pass the calling page as an argument but
in the code of the method this is a generic System.Web.UI.Page and I need
to cast it in the right "pattern page" type to access the controls.
There is where I need to reference the pages.

I hope it is a bit clearer.

Many thaks,

Ugo

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com. ..
>>>Hi all,

I try to reference several pages from a class (ideally located in a
class library). But no namespace is available to do this.

Does anybody have an idea how to do this?

Thanks for your help,

Ugo

What are you trying to do? You can't access them as you can with
winform-windows, where you can read values from hidden windows.
With webforms (asp.net) all page-values are gone as soon as the request
has finished processing.

You *can* get at the current Request or Session, using
System.Web.HttpContext.Current.Request (or .Session).
You will need a project-reference to System.Web.dll for this.
Hans Kesting




Jul 18 '06 #6

P: n/a
Yes, that's right but after, I have to dynamically cast the page into this
retrieved type. How can I do that? And how can the compiler let me call,
let's say: textbox1.enbled = false; onto a type that isn't known at compile
time?

One precision, I work in C#. If it is possible in VB that would be terrific!

Ugo
The Page has a "FindControl" method that you can use to find some
control by name. You can use this to see if there is a textbox named
"TextBox1". If so, cast the control that's found to TextBox and set
it's Visible property (or whatever you want to do with it).
One important note: this FindControl only finds immediate children (at
least in 1.1), so you might want to wrap this in a method that searches
the entire control-tree recursively.

Hans Kesting
>
"Eliyahu Goldin" <re*************@monarchmed.comwrote in message
news:Oh**************@TK2MSFTNGP03.phx.gbl...
>Ugo,

You can always get the type name from the passed "page" parameter as

page.GetType().ToString();
-- Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Ugo Van Noorbeeck" <Va**********@guidance.bewrote in message
news:uV**************@TK2MSFTNGP05.phx.gbl...
>>Hello,

In fact I want to be able to alter my page(s) with a "main controller"
(the class in the class library). I have several pages that differs only
by one textbox or so. And instead of creating new pages, I made a few
"pattern pages" in which I only hide/modify some controls depending on the
page to load. (I don't think Master page can help).
So, in the page_load (or just after) I call the method in the controller
class to make the adjustments. I pass the calling page as an argument but
in the code of the method this is a generic System.Web.UI.Page and I need
to cast it in the right "pattern page" type to access the controls.
There is where I need to reference the pages.

I hope it is a bit clearer.

Many thaks,

Ugo

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com.. .
>

What are you trying to do? You can't access them as you can with
winform-windows, where you can read values from hidden windows.
With webforms (asp.net) all page-values are gone as soon as the request
has finished processing.

You *can* get at the current Request or Session, using
System.Web.HttpContext.Current.Request (or .Session).
You will need a project-reference to System.Web.dll for this.

Hans Kesting



Jul 18 '06 #7

P: n/a
Hello,

This work for me!

Many thanks,

Regards,

Ugo

"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com...
>Yes, that's right but after, I have to dynamically cast the page into
this retrieved type. How can I do that? And how can the compiler let me
call, let's say: textbox1.enbled = false; onto a type that isn't known at
compile time?

One precision, I work in C#. If it is possible in VB that would be
terrific!

Ugo

The Page has a "FindControl" method that you can use to find some control
by name. You can use this to see if there is a textbox named "TextBox1".
If so, cast the control that's found to TextBox and set it's Visible
property (or whatever you want to do with it).
One important note: this FindControl only finds immediate children (at
least in 1.1), so you might want to wrap this in a method that searches
the entire control-tree recursively.

Hans Kesting
>>

Jul 19 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.