473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

function is inaccessible due to its protection

Hi All

I have the code below (Using Delphi 2006 Developer to create an C#
ASP.Net page to update a simple database table. When the page is fired
I get the following error message

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++
Compiler Error Message: CS0122:
'LivLeadTime.WebForm2.Livery_DeleteCommand(object,
System.Web.UI.WebControls.DataGridCommandEventArgs )' is inaccessible
due to its protection level

Source Error:

Line 17:
Line 18: <div align="center">
Line 19: <asp:datagrid
Line 20: id="Livery"
Line 21: runat="server"

Source File: c:\inetpub\wwwroot\LivLeadTime\WebForm2.aspx Line: 19

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++

As I am new to C# (or any C type language) I am finding this hard to
understand. Can anyone tell me what is wrong with this piece of code.

The code is below

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++
The WebForm2.aspx definitions for the form are

<asp:datagrid
id="Livery"
runat="server"
width="92%"
cellpadding="5"
font-size="8pt"
ondeletecommand="Livery_DeleteCommand"
autogeneratecolumns="false"
headerstyle-backcolor="black"
headerstyle-forecolor="white"
headerstyle-font-bold="true"
itemstyle-verticalalign="top"
oncancelcommand="Livery_CancelCommand"
onupdatecommand="Livery_UpdateCommand"
oneditcommand="Livery_EditCommand"
allowsorting="True"
onsortcommand="Livery_SortCommand">

<EditItemStyle borderstyle="Dashed"
bordercolor="#0000C0"
backcolor="#FFFFC0"></EditItemStyle>
<ItemStyle verticalalign="Top"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Black"></HeaderStyle>

<Columns>
<asp:EditCommandColumn
HeaderText="Edit"
EditText="Edit"
ButtonType="PushButton"
CancelText="Cancel"
UpdateText="Update">
</asp:EditCommandColumn>
<ASP:BoundColumn
datafield="LIVNAME"
headertext="Livery Name">
</ASP:BoundColumn>
<ASP:BoundColumn
datafield="LEADTIME"
headertext="Lead Time">
</ASP:BoundColumn>
<asp:buttoncolumn
Text="Delete"
HeaderText="Delete"
ButtonType="PushButton"
CommandName="Delete">
</asp:buttoncolumn>

</Columns>
</asp:datagrid>

and the WebForm2.aspx.cs code is as follows

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
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 LivLeadTime
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid Livery;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if ((! IsPostBack))
{
}
else
{
}
}

#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.Livery.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_CancelCommand);
this.Livery.EditCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_EditCommand);
this.Livery.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.Livery_SortCommand);
this.Livery.UpdateCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_UpdateCommand);
this.Livery.DeleteCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_DeleteCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

private void Livery_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Editing";
}

private void Livery_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Deleting";
}

private void Livery_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
string LString = "Sorting";
}

private void Livery_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Updating";
}

private void Livery_CancelCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Cancelling";
}
}

Jan 9 '07 #1
5 6603
The real confusing thing here is line 19. Line 19 is not just the
asp:datagrid definition however, line 19 refers to the entire element
definition. The problem will be further down the attribute list. I believe
the problem is going to be your reference to the commands such as
Livery_CancelCommand. In the codebehind file, you have Livery_CancelCommand
defined with the private access level. Change this to protected. Do the same
on your other event handlers that are used by the datagrid. The reason is,
since they are defined as private they will only be available from within
the codebehind itself and not on the actual asp.net page. Protected makes
them visibile to the asp.net page, but not publically available to the app
as a whole.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006
"Iain" <Em**************@gmail.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Hi All

I have the code below (Using Delphi 2006 Developer to create an C#
ASP.Net page to update a simple database table. When the page is fired
I get the following error message

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++
Compiler Error Message: CS0122:
'LivLeadTime.WebForm2.Livery_DeleteCommand(object,
System.Web.UI.WebControls.DataGridCommandEventArgs )' is inaccessible
due to its protection level

Source Error:

Line 17:
Line 18: <div align="center">
Line 19: <asp:datagrid
Line 20: id="Livery"
Line 21: runat="server"

Source File: c:\inetpub\wwwroot\LivLeadTime\WebForm2.aspx Line: 19

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++

As I am new to C# (or any C type language) I am finding this hard to
understand. Can anyone tell me what is wrong with this piece of code.

The code is below

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++
The WebForm2.aspx definitions for the form are

<asp:datagrid
id="Livery"
runat="server"
width="92%"
cellpadding="5"
font-size="8pt"
ondeletecommand="Livery_DeleteCommand"
autogeneratecolumns="false"
headerstyle-backcolor="black"
headerstyle-forecolor="white"
headerstyle-font-bold="true"
itemstyle-verticalalign="top"
oncancelcommand="Livery_CancelCommand"
onupdatecommand="Livery_UpdateCommand"
oneditcommand="Livery_EditCommand"
allowsorting="True"
onsortcommand="Livery_SortCommand">

<EditItemStyle borderstyle="Dashed"
bordercolor="#0000C0"
backcolor="#FFFFC0"></EditItemStyle>
<ItemStyle verticalalign="Top"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="White"
backcolor="Black"></HeaderStyle>

<Columns>
<asp:EditCommandColumn
HeaderText="Edit"
EditText="Edit"
ButtonType="PushButton"
CancelText="Cancel"
UpdateText="Update">
</asp:EditCommandColumn>
<ASP:BoundColumn
datafield="LIVNAME"
headertext="Livery Name">
</ASP:BoundColumn>
<ASP:BoundColumn
datafield="LEADTIME"
headertext="Lead Time">
</ASP:BoundColumn>
<asp:buttoncolumn
Text="Delete"
HeaderText="Delete"
ButtonType="PushButton"
CommandName="Delete">
</asp:buttoncolumn>

</Columns>
</asp:datagrid>

and the WebForm2.aspx.cs code is as follows

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
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 LivLeadTime
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid Livery;

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if ((! IsPostBack))
{
}
else
{
}
}

#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.Livery.CancelCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_CancelCommand);
this.Livery.EditCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_EditCommand);
this.Livery.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEvent Handler(this.Livery_SortCommand);
this.Livery.UpdateCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_UpdateCommand);
this.Livery.DeleteCommand += new
System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Livery_DeleteCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

private void Livery_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Editing";
}

private void Livery_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Deleting";
}

private void Livery_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
string LString = "Sorting";
}

private void Livery_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Updating";
}

private void Livery_CancelCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string LString = "Cancelling";
}
}

Jan 9 '07 #2
Hi Mark

Thanks for your help.
Changing the function to protected work.
However, what I cannot fathom is the event handler function was defined
as private by the Delphi 2006 developer ide. eg I double click teh
event in teh object inspector and it creates the event (as any standard
ide would do) so I would have thought that all would be well .
I will check the Borland site and see if therre are any updates

Thnaks againn

Iain

Jan 9 '07 #3
Hi Milosz

Thanks for your help Milosz.
What you pointed out certainly makes sense. I removed teh reference to
the event handlers from the datagrid definition, renamed the functions
from protected to private and it all works now.

Thanks a lot for your help

Iain

Jan 9 '07 #4
Hi Milosz

Both the ASP.Net 1.1 and the ASP.Net 2.0 methods work.
Which in you opinion is the best method to use or is there no
differnece apart from teh definition methodology.

Iain

Iain wrote:
Hi Milosz

Thanks for your help Milosz.
What you pointed out certainly makes sense. I removed teh reference to
the event handlers from the datagrid definition, renamed the functions
from protected to private and it all works now.

Thanks a lot for your help

Iain
Jan 10 '07 #5
Hi Iain,

It's up to you. i would use asp.net 2.0 method because you have to write
less lines of code.

--
Milosz
"Iain" wrote:
Hi Milosz

Both the ASP.Net 1.1 and the ASP.Net 2.0 methods work.
Which in you opinion is the best method to use or is there no
differnece apart from teh definition methodology.

Iain

Iain wrote:
Hi Milosz

Thanks for your help Milosz.
What you pointed out certainly makes sense. I removed teh reference to
the event handlers from the datagrid definition, renamed the functions
from protected to private and it all works now.

Thanks a lot for your help

Iain

Feb 20 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BlueOysterCult | last post by:
Hello I can't get around the error "inaccessible due to its protection level" - it points at a line that I am using .Sort() and BinarySearch() - but the real problem lies in another part of the...
1
by: Larry | last post by:
Thanks in advanced for your help I've added a TextBox1 and Button1 to a form in C# in VS.net 2003. When I double click on the Button1 at design time, a private method ButtonClick. I've...
1
by: Larry | last post by:
I have a VB background and am developing a new windows app in Csharp. I'm getting the error. 'inaccessible due to its protection level' I've added a TextBox1 and a Button1 to a form. I...
1
by: Chris | last post by:
Hi, New to C# programming. I'm trying to implement some simple security in my website. Basically a user cannot surf to secured aspx pages simply by accessing them directly through the address...
3
by: tshad | last post by:
I am getting a message for my objects that say: testNulls.cs(13,33): error CS0122: 'FtsData.IntType.IntType()' is inaccessible due to its protection level I have a class calling objects out of...
2
by: Jason Shohet | last post by:
I have a line: public System.Web.UI.HtmlControls.HtmlTable bldgInfo; Even though its public, for some reason every so often, .NET tells us that bldgInfo table is inaccessible due to the...
1
by: Arjen | last post by:
Hi, I have this inside a webusercontrol: private string MenuItem = new string; Inside the .ascx file I do this: <%= MenuItem(0) %> And I get this error: ....is inaccessible due to its...
2
by: sck10 | last post by:
Hello, I am getting the following error: fvServiceIdea_ItemUpdating_Validate(object, System.Web.UI.WebControls.FormViewUpdateEventArgs)' is inaccessible due to its protection level. Below...
6
by: milund | last post by:
I have a "funny" after upgrading to .NET2.0. The following code is placed inside an unsafe method in assembly "A" System.Object myIUnknownObject =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.