我正在尝试创建一个 webpage
,但是当我创建 button
并添加 method
给它一个compilation error occurs
,当我删除 method
从按钮它工作正常
我尝试了这些步骤
CS1061
在线 Server Error in '/' Application.
Compilation Error
Compiler Error Message: CS1061: 'ASP.usermodification_aspx' does not contain a definition for 'btnModify_Click' and no extension method 'btnModify_Click' accepting a first argument of type 'ASP.usermodification_aspx' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 38: SelectCommand="SELECT RoleName FROM aspnet_Roles"></asp:SqlDataSource>
Line 39: <br />
Line 40: <asp:Button ID="btnModify" runat="server" Text="Modify"
Line 41: onclick="btnModify_Click" />
Line 42:
namespace RentACar
{
public partial class UserModification : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnModify_Click(object sender, EventArgs e)
{
GridViewRow row = gvUserRoles.SelectedRow;
string username = row.Cells[0].Text;
string role = row.Cells[1].Text;
Roles.RemoveUserFromRole(username, role);
string choosenrole = dllUserRoles.SelectedValue.ToString();
Roles.AddUserToRole(username, choosenrole);
}
}
}`
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="UserModification.aspx.cs" Inherits="RentACar.UserModification" %>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
<asp:Button ID="btnModify" runat="server" Text="Modify"
onclick="btnModify_Click" />
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
最佳答案
尝试使用 CodeFile
而不是 CodeBehind
在页面标签中。 CodeBehind 需要编译解决方案。您的代码可能有问题。在页面标签中使用 CodeFile 属性后,在您的按钮事件处理程序上放置一个断点,看看您是否仍然收到该错误。
https://stackoverflow.com/questions/10462833/
相关文章:
ruby - 为什么在编译ruby-1.9.3-p125时出现clang错误?
testing - Flex Builder : Asset file or directory n
iphone - 如何解决iPhone应用程序hpple HTML解析 'libxml/tree.h
apache-flex - 类mx.core::DesignLayer could not be f
visual-studio-2010 - VS2010 Express 中的 Boost - 重新定
actionscript-3 - 1120 : Access of undefined proper