Loading ASP page programatically

Discussion in 'ASP .Net' started by =?Utf-8?B?bWFya2Vib3k=?=, May 11, 2004.

  1. 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
    =?Utf-8?B?bWFya2Vib3k=?=, May 11, 2004
    #1
    1. Advertising

  2. 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
    Steven Cheng[MSFT], May 11, 2004
    #2
    1. Advertising

  3. 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
    =?Utf-8?B?bWFya2Vib3k=?=, May 12, 2004
    #3
  4. Cancel that..

    Opening/Closing the IDE several times and compiling several times fixed it
    =?Utf-8?B?bWFya2Vib3k=?=, May 12, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Harvey

    Refreshing a page programatically

    Simon Harvey, Apr 2, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    418
    Simon Harvey
    Apr 2, 2004
  2. Mark
    Replies:
    5
    Views:
    442
  3. Craig Wilson
    Replies:
    3
    Views:
    4,848
    clintonG
    Nov 12, 2004
  4. Mythran

    Create ASP.Net Page Programatically

    Mythran, Mar 4, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    1,324
    Vinay
    Apr 20, 2007
  5. Mythran

    Create ASP.Net Page Programatically

    Mythran, Mar 4, 2005, in forum: ASP .Net Web Controls
    Replies:
    6
    Views:
    168
    Mythran
    Mar 9, 2005
Loading...

Share This Page