Solved

Need ASP 2.0 Client Side Callback Advice

Posted on 2006-06-22
4
1,368 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:born4code
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:Sammy
Comment Utility
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
0
 
LVL 2

Author Comment

by:born4code
Comment Utility
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.
0
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
Comment Utility
Okay, I see what you mean now.
actually if you do it and debug the application in VS.Net it wil throw an error saying" Response.Redirect cannot be called in a Page callback."
thats being said your best option is to use a clientside location.href="page.aspx"
I can not see anything around that.

Regards

Sammy
0
 
LVL 2

Author Comment

by:born4code
Comment Utility
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.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now