473,387 Members | 1,504 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,387 software developers and data experts.

ASP.NET 2.0 Portal Web Parts - AddWebPart

Okay can't figure out how to get this to work? Works with a standard
TextBox but not my user control? Help is much appreciated. Thanks.

UserControl googleSearch = new UserControl();
googleSearch.LoadControl("GoogleSearch.ascx");
googleSearch.ID = "UserControlGoogleSearch";
WebPart googleWebPart = WebPartManager1.CreateWebPart(googleSearch);
WebPartManager1.AddWebPart(googleWebPart, WebPartZone2, 1);

Exception thrown on last line:

The "path" argument cannot be empty if the "type" argument is
UserControl.

at
System.Web.UI.WebControls.WebParts.WebPartManager. IsAuthorized(Type
type, String path, String authorizationFilter, Boolean isShared)
at
System.Web.UI.WebControls.WebParts.WebPartManager. IsAuthorized(WebPart
webPart)
at
System.Web.UI.WebControls.WebParts.WebPartManager. AddDynamicWebPartToZone(WebPart
webPart, WebPartZoneBase zone, Int32 zoneIndex)
at
System.Web.UI.WebControls.WebParts.WebPartManager. AddWebPart(WebPart
webPart, WebPartZoneBase zone, Int32 zoneIndex)
at _Default.AddWebPart(Object sender, EventArgs e) in
c:\app_dev\SulzerPortal\Default.aspx.cs:line 66

Jul 12 '06 #1
1 1549
I finally was able to resolve this issue. I still think it is a bug and
do not completely understand why one method works and the other
doessn't. Here's the scoop.

UserControl googleSearch = new UserControl();
MODIFIED: googleSearch = (UserControl)LoadControl("GoogleSearch.ascx");
googleSearch.ID = "UserControlGoogleSearch";
WebPart googleWebPart = WebPartManager1.CreateWebPart(googleSearch);
WebPartManager1.AddWebPart(googleWebPart, WebPartZone2, 1);

Instead of calling googleSearch.LoadControl(path), I used the page
LoadControl(path). The page load control seems to maintain the path
argument that was originally passed to it. When you call AddWebPart the
part must be authorized which needs that path argument.

mr******@gmail.com wrote:
Okay can't figure out how to get this to work? Works with a standard
TextBox but not my user control? Help is much appreciated. Thanks.

UserControl googleSearch = new UserControl();
googleSearch.LoadControl("GoogleSearch.ascx");
googleSearch.ID = "UserControlGoogleSearch";
WebPart googleWebPart = WebPartManager1.CreateWebPart(googleSearch);
WebPartManager1.AddWebPart(googleWebPart, WebPartZone2, 1);

Exception thrown on last line:

The "path" argument cannot be empty if the "type" argument is
UserControl.

at
System.Web.UI.WebControls.WebParts.WebPartManager. IsAuthorized(Type
type, String path, String authorizationFilter, Boolean isShared)
at
System.Web.UI.WebControls.WebParts.WebPartManager. IsAuthorized(WebPart
webPart)
at
System.Web.UI.WebControls.WebParts.WebPartManager. AddDynamicWebPartToZone(WebPart
webPart, WebPartZoneBase zone, Int32 zoneIndex)
at
System.Web.UI.WebControls.WebParts.WebPartManager. AddWebPart(WebPart
webPart, WebPartZoneBase zone, Int32 zoneIndex)
at _Default.AddWebPart(Object sender, EventArgs e) in
c:\app_dev\SulzerPortal\Default.aspx.cs:line 66
Jul 14 '06 #2

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

Similar topics

4
by: Accolo1 | last post by:
Help we are looking for this person, do you know them? William wjohnson@accolo.com Title: BEA WebLogic Portal Guru Job #: 03-04468 Check the pulse of your career! Evolve our eCommerce web...
2
by: Benito Ruiz | last post by:
Hello all, I´m searching information about how development .Net Web Parts for SharePoint Portal Server 2003. Where i can found it?? Thank´s a lot.
4
by: dave | last post by:
if i created a web part in vs.net like http://www.devx.com/dotnet/Article/17518/0/page/2 is it possible to use the web part in both the sharepoint services environment and the sharepoint portal...
4
by: Bob Morvay | last post by:
I am interested in any .NET enabled portal solutions that are in the same class as the J2EE BEA Weblogic portal solution. Can anyone point me to articles comparing the available portal solutions...
18
by: Juan Gil | last post by:
I have a problem with this. I installed it in my computer to modify it, but when I try to save the configuration file(xml file) the server returned an error that say that I dont have permissions to...
0
by: ctadlock | last post by:
In .NET 2.0 web parts can be customized for all users (PersonalizationScope.Shared) or for each specific user (PersonalizationScope.User); is there any way to personalize web parts based on a...
3
by: SlimFlem | last post by:
I am new to the WebPartManager stuff and am still learning how to set this up properly. I am creating instances of WebPart classes from loaded DLLs and add them to the Page's WebPartManager. If I...
0
by: sunil | last post by:
Dear All, I have a task at hand...I need to give some basic training to my testers about Portal and how ASP.Net works... I am sure there are articles and videos helping testers understand about...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.