How to load aspx file into asp.net page object.

Last post 05-09-2008 10:53 AM by rmaiya. 6 replies.

Sort Posts:

  • How to load aspx file into asp.net page object.

    05-07-2008, 8:08 AM
    • Loading...
    • subodhdecos
    • Joined on 05-07-2008, 12:01 PM
    • Posts 3

    I have test.aspx file with its code behind located on my hard drive.

    The test.aspx is not part of my web application.

    I want to load this aspx file into the ASP.NET Page object so that I can navigate through some controls in it.

    Basically what I wnat is get list of all the controlls say asp:button in the the given aspx file.

    How to do that ..

    I dont want to use regular expression.

    Reflection could be an option.

  • Re: How to load aspx file into asp.net page object.

    05-07-2008, 1:23 PM
    • Loading...
    • rmaiya
    • Joined on 06-25-2007, 11:08 PM
    • Olympia, WA
    • Posts 1,233

    as far as I know you can not access a class [basically an aspx page is a class]  without referencing it in your project. What u can do is, reference the other web sites assembly in u r prject and use below code

     

     WebForm2 x = new WebForm2();
                foreach (Control ctrl in x.Controls )
                {
                   
                }

    Raghu
    (MCSD.NET, MCAD.NET, MCDBA)
    [Don't forget to click on Mark as answer on the post that helped you ]
  • Re: How to load aspx file into asp.net page object.

    05-07-2008, 5:10 PM
    • Loading...
    • DigiMortal
    • Joined on 01-10-2007, 7:22 PM
    • Tallinn, Estonia
    • Posts 304
    Try to load this aspx file as template and iterate through it's controls collection. If you are able to load it as template then the code behing this page will not run and you don't get any overhead or unexpected behavior.
    Don't forget to mark solution providing post as "Answered".
    It helps others to find correct solutions!

    Also visit my ASP.NET blog!
  • Re: How to load aspx file into asp.net page object.

    05-08-2008, 12:37 AM
    • Loading...
    • subodhdecos
    • Joined on 05-07-2008, 12:01 PM
    • Posts 3

    WebForm2 is on my disk and not part of any assembly, niether it is in any other web application. Its like stand alone file on a disk.

    Now what to do?Smile

  • Re: How to load aspx file into asp.net page object.

    05-08-2008, 1:05 PM
    • Loading...
    • DigiMortal
    • Joined on 01-10-2007, 7:22 PM
    • Tallinn, Estonia
    • Posts 304
    You should still be able to load it as a template dynamically.
    Don't forget to mark solution providing post as "Answered".
    It helps others to find correct solutions!

    Also visit my ASP.NET blog!
  • Re: How to load aspx file into asp.net page object.

    05-09-2008, 7:41 AM
    • Loading...
    • subodhdecos
    • Joined on 05-07-2008, 12:01 PM
    • Posts 3

    How to do that, Please provide some help, some code.

  • Re: How to load aspx file into asp.net page object.

    05-09-2008, 10:53 AM
    • Loading...
    • rmaiya
    • Joined on 06-25-2007, 11:08 PM
    • Olympia, WA
    • Posts 1,233

     here you go

    http://www.dotnetheaven.com/UploadFile/mahesh/DynamicTemplate05112005005542AM/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930  

    Raghu
    (MCSD.NET, MCAD.NET, MCDBA)
    [Don't forget to click on Mark as answer on the post that helped you ]
Page 1 of 1 (7 items)