I am trying to create a webpage
, but when i create a button
and add a method
to it a compilation error occurs
, when i remove the method
from the button it work fine
i tried these steps
- tried delete page, and redo it from from beginning
- find the error
CS1061
online
3.adding method to button with different methods i am exhausted try to find what is the error pls help me!
Server Error in / Application.
Compilation Error
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.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;