473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to delete a generated web part?

I have generated (programmatically) a web part for my site. It was
created at user-login when the user had permissions to view the
web-part control, but the control wasn't already a part of their
viewable list.

if (/* User has permission */ ... )
{
// Load the add-on...
Control uc = this.LoadControl(DB.GetValue("AddOnFile"));
uc.ID = DB.GetValue("AddOnName");

GenericWebPart wp = MyWebPartManager.CreateWebPart(uc);
wp.Title = DB.GetValue("AddOnName");
wp.ChromeState = PartChromeState.Normal;

MyWebPartManager.AddWebPart(wp, this.AddOns, 0);
}

Now.... I've removed permissions from the user for that control for
that user. However, because they had permission to it before it is
still a part of their WebPart list for their page.

How do I programmatically remove it???

Nov 27 '06 #1
1 1277
SimeonArgus wrote:
I have generated (programmatically) a web part for my site. It was
created at user-login when the user had permissions to view the
web-part control, but the control wasn't already a part of their
viewable list.

if (/* User has permission */ ... )
{
// Load the add-on...
Control uc = this.LoadControl(DB.GetValue("AddOnFile"));
uc.ID = DB.GetValue("AddOnName");

GenericWebPart wp = MyWebPartManager.CreateWebPart(uc);
wp.Title = DB.GetValue("AddOnName");
wp.ChromeState = PartChromeState.Normal;

MyWebPartManager.AddWebPart(wp, this.AddOns, 0);
}

Now.... I've removed permissions from the user for that control for
that user. However, because they had permission to it before it is
still a part of their WebPart list for their page.

How do I programmatically remove it???
Okay... I'm NOT a moron.. I promise. =) I was looking all over for
something under GenericWebPart to say "Delete me". However, I never
looked in WebPartManager. Here's how I pulled it off..

for (int x = 0; x < MyWebPartManager.WebParts.Count; x++)
{
if (MyWebPartManager.WebParts[x].Title ==
DB.GetValue("AddOnName"))
{
// if it is no longer enabled, destroy it.
if (DB.GetValue("Enabled") != "Y")
{

MyWebPartManager.DeleteWebPart(MyWebPartManager.We bParts[x]);
}
}
}

Nov 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: serge | last post by:
How can i delete all user stored procedures and all table triggers very fast in a single database? Thank you
0
by: vanGogh | last post by:
I have generated classes based on an Xml schema file (xsd) using the XSD.exe tool. My goal is to: - write an application that can parse XML documents - fill objects (based on the generated...
10
by: ct | last post by:
Hi, Here is my problem: I need to be able to call a virtual method when an object is deleted. class A { public: virtual ~A(); void virtual DestroyRespond();
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
10
by: R.A.M. | last post by:
Hello, I am trying to learn SQL Server. I need to write a trigger which deletes positions of the document depending on the movement type. Here's my code: set ANSI_NULLS ON set...
22
by: Cylix | last post by:
I have a 4row x 1col table, I would like to drop all the content of row three. Since Mac IE5.2 does not suppport deleteRow method, I have also try to set the innerHTML=''; but it does not work. ...
7
by: John | last post by:
Hi In my vb winform data app with sql server 2005 backend, when in dataset I run the data adapter configuration wizard it generates insert and select sql statements but not delete and update. As...
15
by: tom | last post by:
why delete the dynamically allocated memory twice causes an error, see the code below: int _tmain(int argc, _TCHAR* argv) { int *pi = new int(12); cout<<*pi; delete pi; delete pi; }
7
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.