Search code examples
c#asp.neturl-parameterspageloadis-empty

C# ASP Page check parameters and return other page


I have a upperclass that "scans" the url-parameter and should return a specific page. The "scanning" works fine, but the specific page is always blank (there is no htmlsourcecode to see). How to call the specific page and display it?

    public UpperClass()
    {
      Page.LoadComplete += new EventHandler(Page_LoadComplete);      
    }

    protected void Page_LoadComplete(object sender, EventArgs e)
    {
      CheckParams();
    }

    public void CheckParams()
    {
      //... parse url

      if (x != null & y != null)
        new specific_page(x, y); //here I load the specific page
    }

Solution

  • Are the pages that you are trying to display part of your website?

    If so, you should probably create usercontrols, which are reusable composite elements of your website that you can include wherever you want.

    Have a look here: https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/fb3w5b53%28v%3dvs.85%29

    You can then dynamically add any usercontrol from your code-behind. Look at this answer: https://stackoverflow.com/a/2275678/11811533

    Hope this helps.