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. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2hhdW4=?=

    WebPartManager Import method

    =?Utf-8?B?U2hhdW4=?=, Jul 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    421
    =?Utf-8?B?U2hhdW4=?=
    Jul 27, 2005
  2. =?Utf-8?B?Q0JyZXRhbmE=?=

    Programattically control WebPartManager outside of ASP Page?

    =?Utf-8?B?Q0JyZXRhbmE=?=, Nov 16, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    357
    =?Utf-8?B?Q0JyZXRhbmE=?=
    Nov 16, 2005
  3. SlimFlem
    Replies:
    3
    Views:
    3,318
    SlimFlem
    Jan 7, 2006
  4. SlimFlem
    Replies:
    9
    Views:
    1,926
    SlimFlem
    Jan 9, 2006
  5. =?Utf-8?B?QmlsbCBNaWxk?=

    anonynousIdentification and WebPartManager

    =?Utf-8?B?QmlsbCBNaWxk?=, Feb 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,441
    =?Utf-8?B?RFdT?=
    Feb 14, 2006
Loading...

Share This Page