WebPartManager1.CloseWebPart Error

J

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
 
W

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 ([email protected], 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.
 
W

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 ([email protected], 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.
 

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,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top