__doPostBack outside of href causes full page postback

agigefrof

New Member
I have a custom control (ascx) which implements the IPostBackEventHandler interface for intercepting custom events triggered by custom rendered HTML links. In this control I use an update panel and inside the update panel I use a literal control in which I render custom HTML links. When I render the HTML links inside the literal control I use a StringBuilder with the following code:\[code\]sb.AppendFormat ("<a href=http://stackoverflow.com/"{0}\" id=\"custom_iterator_id\">Text</a>", this.Page.ClientScript.GetPostBackClientHyperlink(this, custom_string_param));\[/code\]Hyperlinks are rendered fine, and when clicking on them an asynchronous postback is triggered and a partial update is fired (since all links are rendered inside the Update panel).The problem is that I need to do some custom Javascript before firing the __doPostBack which is rendered with the above code. So here is a simplified version of the changed code:\[code\]sb.AppendFormat ("<a href=http://stackoverflow.com/"javascript:JSFunc{0}\" id=\"custom_iterator_id\">Text</a>", custom_string_param);\[/code\]Also in the ascx markup I use the following code (inside or outside the Update panel):\[code\]<script language="javascript" type="text/javascript">function JSFunc(param) {// custom js code here .... __doPostBack('<%=this.ClientID%>', param);}</script>\[/code\]The problem here is that when a link is clicked it performs a full postback and not a partial one. I also tested more simple versions of the above code and it seems that if you remove the __doPostBack from the href or the onclick events from the link ( tag) and move it to a custom js function which in turns you supply to the link, a full postback is triggered. Note that there is no error on the page and in both cases the code work correctly. The page is rendering correctly depending on the parameters returned from the __doPostBack, but in the second case a full instead of partial postback is firing.Any ideas?Thanks in advance,George
 
Top