Solved

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

Posted on 2008-10-31
7
1,223 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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