Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Button Event Handler scope (private vs public) ?
Message
De
30/08/2005 11:38:34
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Button Event Handler scope (private vs public) ?
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01045181
Message ID:
01045181
Vues:
56
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform