Questions on custom GenericWebPart and WebPartManager class?

Discussion in 'ASP .Net Building Controls' started by Dave, Feb 26, 2008.

  1. Dave

    Dave Guest

    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.
     
    Dave, Feb 26, 2008
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.