我想創建一個webpage
,但是當我創建button
並添加method
給它一個compilation error occurs
,當我從按鈕移除method
它做工精細 我嘗試了這些步驟添加方法導致編譯錯誤C#ASP
- 試圖刪除頁面,並從開始
- 發現錯誤
CS1061
在線
3.adding方法按鈕無線重做不同的方法 我筋疲力盡嘗試找到什麼是錯誤請幫助我!
Server Error in '/' Application.
Compilation Error
說明:該請求提供服務所需資源的編譯過程中出現錯誤。請查看以下具體的錯誤細節並適當修改您的源代碼。
編譯器錯誤消息:CS1061:「ASP.usermodification_aspx」不 包含一個定義爲「btnModify_Click」和沒有擴展方法 「btnModify_Click」接受型 「ASP.usermodification_aspx」的第一個參數可以發現(是否缺少使用 指令或程序集引用?)
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;
@Rob解決方案應該可以工作,你可以發佈按鈕的aspx代碼?從錯誤它看起來很好。 – Habib
好的,我剛剛發佈了它 – xArd
請發佈代碼從ASPX?最上面一行,頁面標籤和按鈕標籤 – Habib