• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ASP.net, C# page constructors.....

Codewiz

Diamond Member
I am inheriting from an existing page.

I have a page gallery.aspx that inherits from GalleryPage. When gallery.aspx loads, I would like to pass a string to the GalleryPage constructor instead of no parameters.

Since this is the page constructor, it only wants to call the constructor with no parameters. How can I accomplish this.

I am more of a java guy myself so this asp.net stuff is killing me.


public class QContentPage : Page, ICallbackEventHandler
{
private string page;
public QContentPage(string page)
{
this.page = page;
}
}

public class GalleryPage : QContentPage
{
public GalleryPage(): base("test"){}

public GalleryPage(string var): base(var){}
}


 
I'm not sure I follow your issue. You could call the base constructor the same way that GalleryPage calls the base implementation, such as:

public DerivedPage() : base("SomeText")

Now if you mean when gallery.aspx actually *loads* and not constructed, no, you can't call the base constructor at that point.
 
I found a way around the issue. Simply put, instead of by default having the default constructor with no parameters invoked, I wanted to override that default behavior and call a constructor that had parameters.

Instead of passing a variable to a constructor, I just modified the default constructor to read the value out of the user session information. It isn't ideal but it works.
 
Back
Top