Im using VS.NET and cant get this simple page to work........ I get:
CS0122: 'dbtest.WebForm2.Button1_Click(object, System.EventArgs)' is
inaccessible due to its protection level
what's wrong, i clicked the Button1 on designform and it created that
onclick event.......
<%@dotnet.itags.org. Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false"
Inherits="dbtest.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body>
<form id="WebForm2" method="post" runat="server">
<asp:TextBox id="Email" runat="server" MaxLength="255"></asp:TextBox>
<asp:RequiredFieldValidator Runat="server" ID="reqEmail"
ControlToValidate="Email"
ErrorMessage="Error....."></asp:RequiredFieldValidator>
<br>
<asp:Button id="Button1" OnClick="Button1_Click" runat="server"
Text="Button"></asp:Button></form>
</body>
</HTML
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary
/// Summary description for WebForm2.
/// </summary
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox Email;
protected System.Web.UI.WebControls.RequiredFieldValidator reqEmail;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
}
}
}Hi,
Either:
Remove OnClick="Button1_Click" from the html part
--or--
Remove the event subscription: this.Button1.Click += new
System.EventHandler(this.Button1_Click); *and* set the accessible level to
protected (recommended), public or internal for the method Button1_Click.
Greetings
Martin
"Lasse Edsvik" <lasse@.nospam.com> wrote in message
news:#DS$U7goEHA.692@.TK2MSFTNGP12.phx.gbl...
> Hello
> Im using VS.NET and cant get this simple page to work........ I get:
> CS0122: 'dbtest.WebForm2.Button1_Click(object, System.EventArgs)' is
> inaccessible due to its protection level
> what's wrong, i clicked the Button1 on designform and it created that
> onclick event.......
>
> <%@. Page language="c#" Codebehind="WebForm2.aspx.cs"
AutoEventWireup="false"
> Inherits="dbtest.WebForm2" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
> <HTML>
> <HEAD>
> <title>WebForm2</title>
> <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
> <meta content="C#" name="CODE_LANGUAGE">
> <meta content="JavaScript" name="vs_defaultClientScript">
> <meta content="http://schemas.microsoft.com/intellisense/ie5"
> name="vs_targetSchema">
> </HEAD>
> <body>
> <form id="WebForm2" method="post" runat="server">
> <asp:TextBox id="Email" runat="server" MaxLength="255"></asp:TextBox>
> <asp:RequiredFieldValidator Runat="server" ID="reqEmail"
> ControlToValidate="Email"
> ErrorMessage="Error....."></asp:RequiredFieldValidator>
> <br>
> <asp:Button id="Button1" OnClick="Button1_Click" runat="server"
> Text="Button"></asp:Button></form>
> </body>
> </HTML>
>
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
> namespace dbtest
> {
> /// <summary>
> /// Summary description for WebForm2.
> /// </summary>
> public class WebForm2 : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.TextBox Email;
> protected System.Web.UI.WebControls.RequiredFieldValidator reqEmail;
> protected System.Web.UI.WebControls.Button Button1;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> }
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> //
> // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> //
> InitializeComponent();
> base.OnInit(e);
> }
>
> /// <summary>
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> /// </summary>
> private void InitializeComponent()
> {
> this.Button1.Click += new System.EventHandler(this.Button1_Click);
> this.Load += new System.EventHandler(this.Page_Load);
> }
> #endregion
> private void Button1_Click(object sender, System.EventArgs e)
> {
>
> }
> }
> }
Martin,
thx, that worked :)
/Lasse
"Martin Dechev" <detcheff_@.hotmail.com> wrote in message
news:ebxVRPioEHA.596@.TK2MSFTNGP11.phx.gbl...
> Hi,
> Either:
> Remove OnClick="Button1_Click" from the html part
> --or--
> Remove the event subscription: this.Button1.Click += new
> System.EventHandler(this.Button1_Click); *and* set the accessible level to
> protected (recommended), public or internal for the method Button1_Click.
> Greetings
> Martin
> "Lasse Edsvik" <lasse@.nospam.com> wrote in message
> news:#DS$U7goEHA.692@.TK2MSFTNGP12.phx.gbl...
> > Hello
> > Im using VS.NET and cant get this simple page to work........ I get:
> > CS0122: 'dbtest.WebForm2.Button1_Click(object, System.EventArgs)' is
> > inaccessible due to its protection level
> > what's wrong, i clicked the Button1 on designform and it created that
> > onclick event.......
> > <%@. Page language="c#" Codebehind="WebForm2.aspx.cs"
> AutoEventWireup="false"
> > Inherits="dbtest.WebForm2" %>
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
> > <HTML>
> > <HEAD>
> > <title>WebForm2</title>
> > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
> > <meta content="C#" name="CODE_LANGUAGE">
> > <meta content="JavaScript" name="vs_defaultClientScript">
> > <meta content="http://schemas.microsoft.com/intellisense/ie5"
> > name="vs_targetSchema">
> > </HEAD>
> > <body>
> > <form id="WebForm2" method="post" runat="server">
> > <asp:TextBox id="Email" runat="server" MaxLength="255"></asp:TextBox>
> > <asp:RequiredFieldValidator Runat="server" ID="reqEmail"
> > ControlToValidate="Email"
> > ErrorMessage="Error....."></asp:RequiredFieldValidator>
> > <br>
> > <asp:Button id="Button1" OnClick="Button1_Click" runat="server"
> > Text="Button"></asp:Button></form>
> > </body>
> > </HTML>
> > using System;
> > using System.Collections;
> > using System.ComponentModel;
> > using System.Data;
> > using System.Drawing;
> > using System.Web;
> > using System.Web.SessionState;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.Web.UI.HtmlControls;
> > namespace dbtest
> > {
> > /// <summary>
> > /// Summary description for WebForm2.
> > /// </summary>
> > public class WebForm2 : System.Web.UI.Page
> > {
> > protected System.Web.UI.WebControls.TextBox Email;
> > protected System.Web.UI.WebControls.RequiredFieldValidator reqEmail;
> > protected System.Web.UI.WebControls.Button Button1;
> > private void Page_Load(object sender, System.EventArgs e)
> > {
> > // Put user code to initialize the page here
> > }
> > #region Web Form Designer generated code
> > override protected void OnInit(EventArgs e)
> > {
> > //
> > // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> > //
> > InitializeComponent();
> > base.OnInit(e);
> > }
> > /// <summary>
> > /// Required method for Designer support - do not modify
> > /// the contents of this method with the code editor.
> > /// </summary>
> > private void InitializeComponent()
> > {
> > this.Button1.Click += new System.EventHandler(this.Button1_Click);
> > this.Load += new System.EventHandler(this.Page_Load);
> > }
> > #endregion
> > private void Button1_Click(object sender, System.EventArgs e)
> > {
> > }
> > }
> > }
0 comments:
Post a Comment