Loading ASP page programatically

G

Guest

I am wanting to control when a page is loaded using a separate class to manage when and how it should be loade

My current implementation needs to set a property of the page programatically (through a defined interface on the page)

I can create an instance of the code behind class (and interface) that the page inherits and implements, however, I have no way of then calling it to load

Of course, this was quite possible in VB6, by implementing an interface on the form, loading the form, setting the interface and property, and then showing the form. How can I achieve this


I
 
S

Steven Cheng[MSFT]

Hi,

From your description, you want to manually control the asp.net web page's
loading via a certain class so that to do some operations before loading
the page or in other word, use the class to do some certain operation on
the page object and then let it load, yes?

As for this question, here are my suggestions:
In VB OR .NET Winform application, we can create a form class's instance
and do some intial operations on it and manually show it that'll cause the
Form_load event be fired. This is because it's in the desktop application
which all the instance a all in the certain machine 's memory.

In asp.net (Or other web application), the application is b/s mode
browser/server, the page is finally display as normal html page in
clientside's browser. The serverside page instance only exist when the web
request is being processing at the serverside. The webrequest will pass
serveral progresses in the serverside which is called asp.net "pipeline" ,
here is a tech article on this:

#The ASP.NET HTTP Runtime
http://msdn.microsoft.com/library/en-us/dnaspp/html/dngrfTheASPNETHTTPRuntim
e.asp?frame=true

And the page instance (infact, it should be called as "PageHandler" is be
instanced at the final progress). At that time, the page's serverside life
cycle begins, it has serval events when during the whole procedure, such as
Init,
Load, PreRender, Render..
All these are called by asp.net runtime, not controlable by us. The
following tech refrence in MSDN maybe helpful for understanding this model:

#The ASP.NET Page Object Model
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspnet-pageobjectmodel.a
sp?frame=true

#Web Forms Page Processing
http://msdn.microsoft.com/library/en-us/vbcon/html/vbconWebFormsPageProcessi
ngStages.asp?frame=true

So I think what we can do is make use of these existing event , for example
the Page_Init or Page_Load event and put our initial processing in these
events. Also, if you want a group of pages which all have some common
precessing before load, you can define a common base page class and hook
the Init event and the other pages will derived from this base page class
so that they'll inherit the processing in the Init event or can Override
it. How do you think of this?

If you have any other ideas or question, please feel free to post
here.Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
G

Guest

Stephe

I can make this work by deriving my pages from a BaseClass which in turn Inherits System.Web.UI.Page. I wanted to force the class inheriting from BaseClass to implement a couple of methods - PageUnLoadHandler() and PageLoadHandler(). I would call these from the BaseClass Page_Load event handler. This would give the code behind class the functionality it needs for customised handling of these Page event

I found when I add the MustInherit keyword to the base class I get a Type Abstract error when trying to view the page in the designer

Now when I remove the keyword, and alter the keywords to the methods, the problem does not go away

Is there a better way to do this

So I think what we can do is make use of these existing event , for example
the Page_Init or Page_Load event and put our initial processing in these
events. Also, if you want a group of pages which all have some common
precessing before load, you can define a common base page class and hook
the Init event and the other pages will derived from this base page class
so that they'll inherit the processing in the Init event or can Override
it. How do you think of this?




Regards

Steven Chen
Microsoft Online Suppor

Get Secure! www.microsoft.com/securit
(This posting is provided "AS IS", with no warranties, and confers no
rights.

Get Preview at ASP.NET whidbe
http://msdn.microsoft.com/asp.net/whidbey/default.asp
 
G

Guest

Cancel that..

Opening/Closing the IDE several times and compiling several times fixed it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top