Reputation: 21282
I have an <asp:Image>
element and a text caption, surrounded by an <a>
element. I need the link to run a method when clicked, changing the ImageUrl property of another <asp:Image>
element.
I'm a total noob with ASP.NET (Clearly.)
Can anyone explain this process to me?
Upvotes: 0
Views: 111
Reputation: 415620
Is changing the image the only thing you're doing? If so, you should probably keep this all in javascript, or least try to use javascript first and only postback if javascript is disabled. Server events are bad for performance.
Upvotes: 5
Reputation: 33143
An imagebutton will be your best bet. It is basically a button but the look of simply an image. There is no depressing or any movement with this control.
Upvotes: 2
Reputation: 8358
I think the ImageButton control will do it for you: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.imagebutton.aspx
It fires a postback, giving you all the events you expect.
Upvotes: 3
Reputation: 73301
Is the Method on the Server?
Then you need to use the ASP.NET Link Control. You can hook up to the OnClick event on the Link Control.
Upvotes: 0