asp.net - asp:ImageButton with PostBackUrl responds after the second click -


i have asp:imagebutton postbackurl same button (code behind) , have click twice in order fire internal code. need know how can solve issue 1 click. please see code bellow.

<asp:imagebutton id="imgbutton"  runat="server"  imageurl="~/images/compose.gif" onclick="imgbutton_click"/> 

code behind:

protected void imgbutton_click(object sender, imageclickeventargs e) {           this.imgbutton.postbackurl = "http://www.externalsite.com/entry.aspx";         //the internal code goes here... (this responds after second click).  } 

you setting postbackurl property on first click, not posting it. on second click posts url because property has been set on first click. either set postbackurl property in markup or response.redirect in button click event.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -