Mephisztoe
Mephisztoe

Reputation: 3314

Getting ASP.NET ImageButton OnClientClick changes to the server

I use an ASP.NET ImageButton on my website. When a user clicks on the ImageButton, a javascript is fired via the OnClientClick event. The script changes the ImageUrl of the ImageButton.

On the same page, I have a submit button.

Clicking the button causes a post back to appear.

Is there a way of knowing the correct ImageUrl of the ImageButton from serverside now when processing the serverside OnClick event of the submit button?

Upvotes: 0

Views: 1540

Answers (3)

SKDl
SKDl

Reputation: 11

or you could just use this in your codebehind:

protected void imageclicked(object sender, eventargs e)
{
 ImageButton ClickedButton = sender as ImageButton;
}

then you can use ClickedButton.ImageUrl

Upvotes: 1

Henry Gao
Henry Gao

Reputation: 4936

You can add a hidden field to record what's the image name each time when clien side script fired. When postback, you just check the value of this field.

Upvotes: 0

ashish jaiman
ashish jaiman

Reputation: 389

can you store that changed inage url in a hidden text box and at postback you can get the text box.

Upvotes: 1

Related Questions