Link to home
Start Free TrialLog in
Avatar of born4code
born4code

asked on

Need ASP 2.0 Client Side Callback Advice

I've had some success with the Client Side Callbacks in asp 2.0, but recently discovered, there may be no way to refresh the page after a client side callback has run.  I get errors with server.transfer or response.redirect.  I've also read on the web that this is true, and a known downside to using callbacks.

The only way I have successfully worked around this, is to use the javascript method "location.href='somepath.aspx'"... at the end of my client side callback (jscript) function.  But, was a little worried that a method like that would send off alarms on some computers.  Just not sure.

Anyone have a workaround that does not involve using javascript to refresh the page after a client side callback?

(ha, it is frustrating when I can just take my mouse and click on the 'refresh' button at the top of my browser to do this.)

thanks
Avatar of Sammy
Sammy
Flag of Canada image

born4code,
Can you please post the code you are using for the clientcallback? I was trying to recreate any errors after client call back using C# 2.0 and have not gotten any. the one thing that broken my call back was Response.Write("...."); transfer and redirect worked without a glitch.

Regards
Sammy
Avatar of born4code
born4code

ASKER

It's pretty straightforward... attaching this to my html element onClick....

            CurrentControl.Page.ClientScript.GetCallbackEventReference(CurrentControl, _
                    "'myprocedure'", "MyCallBack", "null", "MyErrCallBack", True) & _
                    ">Click Me</a>"

Then in the callback...

    Public Sub RaiseCallbackEvent(ByVal eventArgument As String) Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
''     <<<< anything in here....
      Response.Redirect("thepage.aspx")
    End Sub

Couple things to keep in mind... first... it's commonly documented that response.redirect and server.transfer will not work during a client side callback.  But, one thing that documentators forget to mention... if you use an Html control, like an HtmlButton... the page load event WILL fire.  If you mark the button as a "submit" type, it will fire twice.

But in this case... just simple html link.
ASKER CERTIFIED SOLUTION
Avatar of Sammy
Sammy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Okay.  The other way is to use the HtmlButton control or some other Html control, which will definitely fire the page load.  However, I am loading in the controls dynamically, and in this case, just DHTML.  So, when using the Html controls I can achieve the desired result... BUT, a dynamically loaded Html control requireds that I put in <pages enableEventValidation="false"> into my web.config file... and I'm not that familiar with the security holes using this.  Hey, what a great question... perhaps.

Thanks.