Home All Groups Group Topic Archive Search About

WebPartManager1.CloseWebPart Error

Author
13 Jul 2006 2:08 PM
Jerry C
I am trying to close a webpart in a WebPartZone. There is a WebPartManager
and CatalogZone on the page.
The WebPartZone  looks like this

<ZoneTemplate>
                            <uc1:DDEstimate ID="DDEstimate1"
title="Estimate" runat="server" />
                            <uc2:DDStationVendor ID="DDStationVendor1"
title="Vendor Summary" runat="server" />
                            <uc3:DDEstimateLog ID="DDEstimateLog1"
title="Estimate Status Log" runat="server" />
                            <uc5:DDEmailToDownloadAlert
ID="DDEmailToDownloadAlert1" title="Traffic Manager Alerts" runat="server" />


                         </ZoneTemplate>


I am trying to use the code:
WebPartManager1.CloseWebPart(DDEmailToDownloadAlert1)
to close the webpart and getting the error:
Error    10    Value of type 'ASP.ddemailtodownloadalert_ascx' cannot be converted
to 'System.Web.UI.WebControls.WebParts.WebPart'.

Thank you





--
Jerry

Author
14 Jul 2006 9:42 AM
Walter Wang [MSFT]
Hi Jerry,

When using User Control or Server Control as WebPart, they will be wrapped
with GenericWebPart, which can be referenced by the control's Parent
property:

WebPartManager1.CloseWebPart(CType(DDEmailToDownloadAlert1.Parent,
GenericWebPart))

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
18 Jul 2006 8:32 AM
Walter Wang [MSFT]
Hi Jerry,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!

Regards,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.