Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Button Event Handler scope (private vs public) ?
Message
From
30/08/2005 11:38:34
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Button Event Handler scope (private vs public) ?
Environment versions
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01045181
Message ID:
01045181
Views:
58
ASP.NET v1.1 (VS.Studio 2003)

I add a LinkButton named "lnkExport" and double-click on it.
A method gets created automagically with the following signature:
private void lnkExport_Click(object sender, System.EventArgs e)
{
}
and this gets added to InitializeComponent()
this.lnkExport.Click += new System.EventHandler(this.lnkExport_Click);
All very nice. I add a Response.Write("Clicked") in lnkExport_Click() to see it working and run the page.
I get a runtime error that object is inaccessible due to its protection level. I then make lnkExport_Click() public and it works.

Why? Why does it need to be public when it is in the same page? All it does is it runs the code as a PostBack AFAIK.
I fail to see why the auto-created private signature does not work.


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Next
Reply
Map
View

Click here to load this message in the networking platform