views:

280

answers:

2

In visual studio 2008 when I drag and drop asp controlXXX on aspx page. Property page for this control, does not show event handlers button. It can reappear after switching to designer view but then disappears again. Screenshot attached.

A: 

Yes, that's annoying, but it works probably only in designer. But you can still add event handlers manually

in html add onclick property and write name of the method

<asp:ImageButton ID="btnAdd" runat="server" onclick="btnAdd_Click" />

and in code-behind add method with two parameters of types: (object, EventArgs) like this:

protected void btnAddTag_Click(object sender, ImageClickEventArgs e)
{
}

or you can also add event handler in Page_Init method

btnAdd.Click+=new ImageClickEventHandler(btnAdd_Click);

(this will also generate automatically the method, only after += press TAB twice)

Jan Remunda
Thanks for answer. I am new to asp and web development, but isn't there more events that just "click" that can be resulted in post back. How do I suppose to add them?
Boris
I mean this is such a basic functionality I am amazed it is not working.
Boris
That's unfortunatelly limitation/bug of Visual Studio. Properties windows is probably primary build to work with Designer.
Jan Remunda
I can hardly believe they meant it to work in designer only.Really annoying is that it happens on my machine only. All other developer have it working. It is terribly inconvenient. There must be something wrong with configuration.
Boris
A: 

what I have check and analyzed is, for any control you add in .aspx page and try to view properites and it is not showing Eventhandler section. you then go the design view and view properties it is showing event handler now and now then if you go to .aspx page try to view properties, event handler section are now there.

Might be visual studio cache the property section for specific control and if you try to view properties from .aspx page, then it is showing but not confirm.

Muhammad Akhtar
How do I cause cache to be refreshed?
Boris
I don't know, but you can check from internet
Muhammad Akhtar