Compiler Error Message CS1061 but I have defined my event handler ASP.net/C# [closed]
So this error is coming from an attempt to solve another issue I am having with Telerik RadGrid but I feel like this problem is just due to the fact that I never actually written a full C# program before an I am picking up someone else's code. I realize that about 100 other people have posted this same question but none of those solutions helped. I have deployed my dlls, manually regenerated the designer file, renamed the event handled, checked its not repeated anywhere and I don't know what else to do.
The top of my ascx file:
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="blahblah.ascx.cs"
Inherits="blah.blahh.blahblah" %>
<%@ Register Assembly="Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4"
Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
The event I'm trying to handle is OnNeedDataSource used for the Telerik RadGrid sorting and paging. So heres a couple pieces of my code the ascx file:
<telerik:RadGrid HeaderStyle-BackColor="#1C5E55" AllowAutomaticInserts="false"
AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" OnDeleteCommand="rgCanonicalRelationships_DeleteCommand"
CommandItemStyle-CssClass="ms-stylelabel" AutoGenerateColumns="false" runat="server" OnNeedDataSource="rgCanonicalRelationships_NeedDataSource"
Skin="Web20" CommandItemStyle-Font-Names="tahoma" CommandItemStyle-Font-Size="XX-Small" AllowSorting="true">
<MasterTableView AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false"
BorderStyle="Solid" BorderWidth="1px" HeaderStyle-BackColor="#1C5E55" ItemStyle-BackColor="LightGray"
CommandItemDisplay="None">
</MasterTableView>
</telerik:RadGrid>
and here is the code-behind properly linked
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
using System.Collections;
using System.Web.Services;
using Telerik.WebControls;
namespace blah.blahh
{
public partial class blahblah :
{
with my function defined:
protected void rgCanonicalRelationships_NeedDataSource(object sender, EventArgs e)
{
BuildCanonicalRelationshipsTable();
}
I'm trying to avoid posting all of my code so if you need to see more let me know. I've been struggling with this for a while and I feel like theres something I'm supposed to do and just haven't Using this OnNeedDataSource event was the suggested way to fix the problem of having my grid disappear on sorting and only reappear upon rebinding the grid
Edit: Sorry forgot about the Error message since I've been seeing it so much:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1061: 'ASP.blah_blahh_blahblah_ascx' does not contain a definition for 'rgCanonicalRelationships_NeedDataSource' and开发者_C百科 no extension method 'rgCanonicalRelationships_NeedDataSource' accepting a first argument of type 'ASP.blah_blahh_blahblah_ascx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 113: <tr class="ms-stylelabel"> Line 114: <td colspan="2"> Line 115: <telerik:RadGrid HeaderStyle-BackColor="#1C5E55" AllowAutomaticInserts="false" Line 116: AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" OnDeleteCommand="rgCanonicalRelationships_DeleteCommand" Line 117: CommandItemStyle-CssClass="ms-stylelabel" AutoGenerateColumns="false" runat="server" OnNeedDataSource="rgCanonicalRelationships_NeedDataSource"
Source File: c:\Inetpub\wwwroot\wss\VirtualDirectories\3718\blah\blahh\blahblah.ascx Line: 115
Clear your Temporary ASP.NET Files
The method recommended in the linked post seems a bit wonky to me. I prefer the following batch script. Note that this script must be run as an Administrator under Windows Vista / 7.
REM del deletes all of the files in the root of the given directory
REM for...rmdir removes all of the subdirectories (and any files inside them) underneath the given directory
iisreset /stop
del /F /Q "%WINDIR%\Microsoft.Net\Framework\v1.1.4322\Temporary ASP.NET Files\*"
for /d %%i in ("%WINDIR%\Microsoft.Net\Framework\v1.1.4322\Temporary ASP.NET Files\*") do rmdir /q /s "%%i"
del /F /Q "%WINDIR%\Microsoft.Net\Framework\v2.0.50727\Temporary ASP.NET Files\*"
for /d %%i in ("%WINDIR%\Microsoft.Net\Framework\v2.0.50727\Temporary ASP.NET Files\*") do rmdir /q /s "%%i"
del /F /Q "%WINDIR%\Microsoft.Net\Framework\v4.0.30319\Temporary ASP.NET Files\*"
for /d %%i in ("%WINDIR%\Microsoft.Net\Framework\v4.0.30319\Temporary ASP.NET Files\*") do rmdir /q /s "%%i"
iisreset /start
Update #1
If clearing your Temporary ASP.NET Files doesn't solve the problem, I would suggest creating a new UserControl and copying the markup and the code-behind from the old UserControl (excluding the CodeBehind
and Inherits
declarations in the markup and the class name of the code-behind file). The CS1061 error can occur if the name of the markup file / code-behind file / code-behind class are not synchronized, and creating a new UserControl is the simplest way to ensure that is not the case.
As I expected due to my inexperience working with ASP and the software and environment I'm working in I was just compiling wrong and hence everything was getting messed up even though some stuff was working so it seemed ok.
精彩评论