Questions on custom GenericWebPart and WebPartManager class?

D

Dave

In
http://msdn2.microsoft.com/en-us/li...bcontrols.webparts.genericwebpart(VS.80).aspx

it states...
"..If you inherit from the GenericWebPart class, you also need to inherit
from the WebPartManager class and override its CreateWebPart method to enable
it to create your custom control..."

However, I've tried this using two classes

public class CustomGenericWebPart : GenericWebPart
{
public CustomGenericWebPart(Control control) : base(control) {}
}

public class CustomWebPartManager : WebPartManager
{
public CustomWebPartManager()
{
//
// TODO: Add constructor logic here
//
}

override public CustomGenericWebPart CreateWebPart (Control control)
{
CustomGenericWebPart customWebPart; //just to see if I can return
it....
return customWebPart;
}
}

error...
return type must be 'System.Web.UI.WebControls.WebParts.GenericWebPart' to
match overridden member
'System.Web.UI.WebControls.WebParts.WebPartManager.CreateWebPart(System.Web.UI.Control)'

Do I have somehow use the "new" when declaring this? When I tried that it
stated

Type 'CustomWebPartManager' already defines a member called 'CreateWebPart'
with the same parameter types.

I'm having a hard time finding any sample code but apparently you can do
according the MS link.
 

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,996
Messages
2,570,237
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top