Solved

WebUserControl - 'WebUserControl.ascx.cs' does not contain a definition for..?'

Posted on 2008-10-31
7
1,220 Views
Last Modified: 2013-12-17
I'm having a problem with a webusercontrol that contains a button embedded within an editor control. The button has a server side method "Editor_SubmitClicked" but for some reason this definition is not found.

here is the error message:

Error      4      'WebUserControl.ascx.cs' does not contain a definition for 'Editor_SubmitClicked' and no extension method 'Editor_SubmitClicked' accepting a first argument of type 'WebUserControl.ascx.cs' could be found (are you missing a using directive or an assembly reference?)      

Any ideas?

0
Comment
Question by:ChiBella
  • 3
  • 2
  • 2
7 Comments
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22854151
Check if the method call and actual method has same parameter types and same number of parameters and return type
0
 

Author Comment

by:ChiBella
ID: 22854242
Yes, I pulled this code out of a web form directly where it works with no problem.




 

WebUserControl.ascx
 

<ed:Editor ID="editorQ1" runat="server" Appearance="custom" Height="180" 

 ModeHTML="false" ModeSwitch="false" ShowQuickFormat="false" Width="400"

OnClickSubmit="Editor_SubmitClicked">
 
 
 

and code behind ascx:
 

protected void Editor_SubmitClicked(object sender, EventArgs e)

    {

//update database here...
 

           }

Open in new window

0
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22854269
have you added tag prefix ed in web.config?

can you post the code that is giving error
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:ChiBella
ID: 22854303
This is a compile error...where the EditorSubmit_Clicked event in the code behind cannot be found.

I have tags for the editor in the ascx page:



<%@ Control Language="C#" ClassName="WebUserControl.ascx.cs"  %>

<%@ Register Assembly="obout_Editor" Namespace="OboutInc.Editor" TagPrefix="ed" %>

Open in new window

0
 
LVL 16

Accepted Solution

by:
ororiole earned 250 total points
ID: 22855735
Change ClassName="WebUserControl.ascx.cs"  to CodeBehind="WebUserControl.ascx.vb" Inherits="<yourNamespace>.WebUserControl1"
0
 
LVL 16

Expert Comment

by:ororiole
ID: 22855737
Oops, make that CodeBehind="WebUserControl.ascx.cs" Inherits="<yourNamespace>.WebUserControl1"
0
 
LVL 13

Assisted Solution

by:TechTiger007
TechTiger007 earned 250 total points
ID: 22856022
The below error means that  your compiler is looking for the method in the class "WebUserControl.ascx.cs". I think your class name is not this.
"'WebUserControl.ascx.cs' does not contain a definition for'WebUserControl.ascx.cs' does not contain a definition for"

Your tags attributes are wrong. Follow the steps suggested by ororiole to fix this error
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now