User control within a web part
-
Friday, March 19, 2010 8:05 PM
Hello, I have some troubles with my webpart in project/pwa (sharepoint)
I have a Web Application project in witch I added a Web User Control. Then I added a Web Part to the Solution.
Then I created this folder structure in the web part project: Templates/ControlTemplates/{Name of my WebPart Project}. Inside this folder I added the User Control as a link.
After compiling with no error. When I try to add my webpart in the project/pwa site I get this error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: 'CalendarioWP.WebUserControl, CalendarioWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bbf1f0c49f6f892c' is not allowed here because it does not extend class 'System.Web.UI.UserControl'.
Source Error:Line 1: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl.ascx.cs" Inherits="CalendarioWP.WebUserControl, CalendarioWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bbf1f0c49f6f892c" %>
Line 2: <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
Source File: /WebUserControl.ascx Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016
But my WebUserControl.ascx.cs looks like this
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication
{
public partial class WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Why do I get this error?
Thanks for your help,
Pablo
- Moved by Mike Walsh FINModerator Friday, March 19, 2010 8:18 PM pwa comes only with Project Server. The SP forums are not support forums for Project Server. Post to microsoft.public.project.server (newsgroup) (From:SharePoint - Development and Programming (pre-SharePoint 2010))
All Replies
-
Monday, March 22, 2010 8:24 AM
Hi, Pablo
How did you warp and deploy the user control web-part?
Would you please first check your strong name class library CalendarioWP.WebUserControl(Inherits tag) ? Did this assembly correctly deployed in GAC? The code logic is actually located there.
<%@ Control Language="C#" CodeBehind="WebUserControl.ascx.cs"
Inherits="CalendarioWP.WebUserControl, CalendarioWP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bbf1f0c49f6f892c" %>
If you moved this control from a web-app, then you need to deploy this webpart in a different approach:
Build the web application solution, put your built dll in bin folder, the webpart is only to wrap the “UserControl”, do not need class with strong name.
Please also see the following, which would help you to better understand how to wrap a user-control:
http://oidatsmyleg.wordpress.com/2009/07/23/wrap-a-user-control-inside-a-web-part-using-wspbuilder/
Hope this can help.
Best Regards,
-Aaron
- Marked As Answer by pabloll Tuesday, March 23, 2010 12:54 PM
-
Monday, March 22, 2010 8:27 AMModerator
Hello Pablo,
Thank you for your post! I would suggest posting your question in one of the MS Forum,
located here: http://forums.asp.net/145.aspx
Have a great day!
Shrikant Maske Tier 2 Application Support Server and Tools Online Operations Team- Proposed As Answer by Shrikant MaskeModerator Monday, March 22, 2010 8:27 AM
-
Tuesday, March 23, 2010 12:54 PM
Thank you Aaron, I followed the link you said and fixed the problem.
Best,
Pablo
-
Saturday, April 17, 2010 9:33 PM" If you moved this control from a web-app, then you need to deploy this webpart in a different approach:
Build the web application solution, put your built dll in bin folder, the webpart is only to wrap the “UserControl”, do not need class with strong name."
>If you moved this control from a web-app, then you need to deploy this webpart in a different approach
May i know what is the other approach?
I really don't want the DLL from the Web Application in my Webpart. So after all what is the way to build the ascx and then pass it to the webpart inerithing in my case
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ControlNowIssues.ascx.cs" Inherits="ListaDeIssues.NowIssues, ListaDeIssues, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxx" %>
Note: Using WSPBuilder, andi havethe exactly Same Error of the original poster
Thank You for helping