Ascx User Control Problems


I am getting started into user controls and I have run accross this problem:

Parser Error

Server Error in '/SinfMonitor' Application.

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: '' is not allowed here because it does not extend class 'System.Web.UI.UserControl'.

Source Error:

Line 1:  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="menu.ascx.cs"  Inherits="" %>
Line 2: <link href="App_Themes/style.css" rel="stylesheet" type="text/css" />
Line 3: <div>

Source File: /sinfmonitor/Menu.ascx    Line: 1

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


This is the output when I test my site. Inside MVS2008 the control renders perfectly.

The menu.ascx relevant code is the following:


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="menu.ascx.cs"  Inherits="" %>
<link href="App_Themes/style.css" rel="stylesheet" type="text/css" />

  and the main page's is:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SinfMonitor3._Default" %>
<%@ Register TagPrefix="control" TagName="menu" src="Menu.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<link href="App_Themes/style.css" rel="stylesheet" type="text/css" />
<control:menu runat="server">

 The only thing I can think of is some sort of cross-referencing error, but I have no idea what it is.

Am I making any huge dumb mistake?

Crappy Web Developer at ISEGI-UNL (Portugal)

Mark as answer if my reply is somewhat insightful. Or helped you in any way!
5/4/2009 3:00:42 PM 93655 articles. 6 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 37

Check your backend code of the .ascx and make sure it looks like this. Be cautious when you change the names of your controls because you have to change it again in the .ascx.cs file and in the .ascs file. If this doesn't help then you need to add a reference to your project to use System.Web.UI .


using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

public partial class yourUserControl : System.Web.UI.UserControl


protected void Page_Load(object sender, EventArgs e)






Mark as answered for quick learning. Mark as don't understand for the concept.
5/4/2009 3:19:58 PM


It seems like your inherits clause in menu user control is wrong. It is probably "SinfMonitor3_menu"..

if it doesn't help you can just remove inherits tag as you aren't inheriting anything..

Hope this helps..

(please mark as an answer, if this helps you.)
5/4/2009 3:25:22 PM


I did check the codebehid before. The only reference missing was xml.Linq. I have added only system.Xml since xml.Link is not compatible with 2.0 (wich I am developing in). Can't hurt to add it. Anyway, the system.web.ui was there.

- But, it didnt solve my problem.


Renaming  the inheritance to Sinfmonitor_menu wont solve the problem. I do think the "." is the correct form tho, since its "namespace.inheritance" - same happening with Sinfmonitor._menu. That's not the problem.

on a second note - removing the inheritance works - so marking your reply as an answer =)

Crappy Web Developer at ISEGI-UNL (Portugal)

Mark as answer if my reply is somewhat insightful. Or helped you in any way!
5/4/2009 3:51:41 PM

Similar Artilces:

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

A Web User Control (*.ascx) Problem?
 Hi dear friends! This is my Q , please help me: I have created a Web User Control containing a Imagemap control and a Panel control below the imagemap. And I have created a property for my control that determines ImageUrl for Imagemap control. Now in my default.aspx I want to add my custom control twice (for example) and want to have different contents in Panel control of my custom control, so I can't. In a simple word from default.aspx file I can't put for Ex. A calendar control in Panel Control and add another instance of my control and put content to second contr...

Web User Control form problem
I have  web form with web user control(ascx page), i will generate query at the user control. form web form i will pass the < table name >use in query to the user control. exaple my query "select * from " & tablename (query is generate at web user control, table name is pass from web form when page_load events) it everything works fine. but i facing problem when have 2 user to log in to the web site for example User A open "member page" so when page load it will pass "Member" to the web user control and the query become "select * from Member" and then User B &nb...

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

calling user control (.ascx) in web form?
Hi, I have a user control file which is displaying a data grid, the code including "Sub Page_Laod()" ... Originally, this part is in my .aspx page ... now I seperate it in a user control file, and use <%@ Register TagPrefix="dg" TagName="dgCC" Src="\ss1\control\dg.ascx" %> to call the user control file in my .aspx page. I have 2 questions ... 1) which one is faster? Using user control or includes the data grid part in my .aspx page directly? I create a user control coz' other pages might need to use the same data grid. 2) In my user control page,...

Web user control form design problemes
when i try to edit the design of my web user control i got an error saying that my BASE object is not set to an instance of an object ! How can i fix that thank you !! was working fine but without any changes it does that !! i use 2003 !! /////////HERE MY BASE OBJECT/////// using System; using System.Data; using System.Collections; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace LNHockey { public class LeagueModuleControl : System.Web.UI.UserControl { Hashtable _se...

Problem creating new web forms and user controls
I have been coding .net for almost a year. Three days ago I created a new project and then some new web forms. Compiled, then viewed the site. I get an error saying it cannot load type - then shows the inherited class for the code behind of the page. This is only happening in certain sites, and we have strict procedures when creating them. They are all the same. Any help would be great Check if you are creating the name spaces properly...(if you have any) rebuild the whole project and then try it out...Hey! It compiles! Ship it! Cheers, Venugopal Mallarapu. Visit : My Blog...

Web Form and Web User Control
Hello, I have a Web User Control (ascx) that includes a button. This button has an onclick event method. This Web User control is included into a Web Form. (thru LoadControl). However, when I click on the button, the event method is not executed. What should I include in order it works fine? Thanks in advance. GAA. Using Loadcontrol is using dynamic controls and when using dynamic controls you must recreate the same dynamic controls ono postback to econstruct the page control tree. It is best if you do this during the Page PreInit event. How complex are your controls ...

problem with web controls in user control
I created user control (x.ascx). in my user control I used: <asp:textbox id="asptextbox" runat="server"></asp:textbox> I put this user control in web form aspx : <form id="thisForm" onSubmit="return checkForm()" method="post" runat="server"> <test:x id="TopTable" name="TopTable" runat="server"></test:x> <--user control </form> my question is: I can’t access In function in JavaScript to the web control (<asp:textbox...

How to access individual controls from a form containing the web user control containing those controls
 Below is a block of code in my .aspx form named default.aspx. In this form I load a web user control. I then add it to a place holder control.(Lines 3 and 4 below) So how do I access the individual controls in my web user control? I want to set the properties on those controls, but I am baffled as to how to access the control. For example I have a text label control named "label3". How do I access this control. Because for example, under certain situations I want to hide that control. ( Label3.Visible = false;)  1    if(!Page.IsPostBack) 2&nb...

Web User Control Not rendering in Web Form
I have created a Web User control that is made up of a Multiview with 2 views inside the Multiview. I have buttons on both views and a gridview on 1 view. My question is when I drop this Web User Control on a Web Form all I see is [MultiView"MultiView1"] and when I view the from in the browser I dont see the Web User Control. I was wondering if someone could please tell me why the Web User Control is not displaying or rendering.     Thanks In Advance Hi, Please check your aspx file for correct reference, like following example: TestControl.ascx:<%@ Control ...

custom web user control and web form
Guys,          I am trying to develop a context menu control for all of my pages. what i am trying to do is that i want the control to pick a datasource from the markup and then check whether its an xml file or a datatable. I created a class called datasource.   /**************************DataSource Class****************************/  public class DataSource { /// <summary> /// This is to identify unique elements from the markup /// </summary>protected string _ID; /// <summary> /// This will be the Datasource ID e...

Calendar control in web user control (ascx)
I have a web page called calendar.aspx It has calendar control and onselectionchanged i have a procedure (Change_Date). Protected Sub Change_Date(ByVal sender As System.Object, ByVal e As System.EventArgs) If Not Request.QueryString("textbox") Is Nothing Then Dim strScript As String = "<script>window.opener.document.forms(0)." + Request.QueryString("textbox").ToString + ".value = '" strScript += CalPopup.SelectedDate.ToString("MM/dd/yyyy") strScript += "';self.close()" strScript += "</" + "script>" RegisterClientScriptBlock("Calendar_ChangeDate", strScript) End If ...

Dynamic Control problem in Web user control
hi friends, i am developing an web user control.   in that i require to add RADEditor control dynamically when the user press ADD button.   But i am unable to retain the control when the page is post back.   Can anybode send me the sample..   Note that it should be in an Web User Control  Just to make sure, Did you place the code addinthe control dynamically inside the "if (!IsPostback)" inside the page_load? santhoshonet: hi friends, i am developing an web user control.   in that i require to add RADEditor control dynamically when the...

Web resources about - Ascx User Control Problems -

Problem novel - Wikipedia, the free encyclopedia
Working class, or proletarian novels are often also social problem novels . This was in many ways a reaction to rapid industrialization , and ...

Malcolm Turnbull's first 100 days as Prime Minister: Successes and problems
December 23 marks 100 full days as Prime Minister for Malcolm Turnbull. How has he fared? Lisa Cox looks at his successes and the headaches. ...

Malcolm Turnbull's first 100 days as PM: agile, disruptive, but problems persist
As the nation winds down for the summer break, its newly installed&nbsp;leader will be working through after deciding that with&nbsp;just three ...

China's Shenzhen ignored warnings of waste problem a year before landslide disaster
A government official warned a year ago that China's boomtown Shenzhen would run out of space to dump building waste. On Sunday his worst fears ...

Malcolm Turnbull's first 100 days as Prime Minister: Successes and problems
December 23 marks 100 full days as Prime Minister for Malcolm Turnbull. How has he fared? Lisa Cox looks at his successes and the headaches. ...

Malcolm Turnbull's first 100 days as Prime Minister: Successes and problems
December 23 marks 100 full days as Prime Minister for Malcolm Turnbull. How has he fared? Lisa Cox looks at his successes and the headaches. ...

"When there’s a problem, people need someone or something to blame. Among L.A. residents peeved with ...
... they’d take their garden-wrecking, loudly squawking, prolifically pooping selves and fly the coop...." Did you know L.A. has a peacock problem ...

Merkel-Enhanced Migration Problem: Million Refugees Hit Europe, 80% Through Greece by Boat; Turkish Mafia ...
... made their way to Europe this year. Every country is complaining now, even Germany. So why isn't anything concrete being done? Why the Problem ...

Maps Minutes Hack #7: No signal, no problem. Navigate your holiday travels with Google Maps offline
Part of our series on how to save time this holiday season with Google Maps. This time of year, millions take a road trip home for the holidays ...

Lawler: "Yes, Houston will have a problem next year"
Some thoughts on the Houston housing market from housing economist Tom Lawler: Earlier this week I sent out a message with a link to the Houston ...

Resources last updated: 12/23/2015 4:17:05 AM