0

In the below code , what is the 'e' in 'e.X.ToString()' and how do you know that you have to use the letter 'e', what does it represent , I can get around this bit


please help

public partial class ImageTest : System.Web.UI.Page
{
protected void ImgButton_ServerClick(Object sender,
ImageClickEventArgs e)
{
Result.InnerText = "You clicked at (" + e.X.ToString() +
", " + e.Y.ToString() + "). ";
if ((e.Y < 100) && (e.Y > 20) && (e.X > 20) && (e.X < 275))
{
Result.InnerText += "You clicked on the button surface.";
}
else
{
Result.InnerText += "You clicked the button border.";
}
}
}

Edited by __avd: Added [code] tags.

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by zachattack05
0

e is a class of type ImageClickEventArgs.
It is an argument of the ImgButton_ServerClick method.
The other argument is sender which is of type Object.
It is some sort of convention to name these arguments that way.

0

I don't know why people do name their arguments e; I've always named mine close to the event type itself. Like EventArgs is eaThisPartDependsOnMethodNameLOL. Well at least it was answered correctly before I got here. LOL

1

I use e just because I think VS uses it by default, instead of confusing future viewers of my code, I keep the e. Chances are high that they will know what it is when reading an event triggered method.

Could just be me being naive though.

Votes + Comments
e for eventargs, everyone recognizes it. Just use it :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.