Solved

Need ASP 2.0 Client Side Callback Advice

Posted on 2006-06-22
4
1,376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:Sammy
ID: 16966486
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
ID: 16973953
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
ID: 16974757
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
ID: 16977309
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 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