Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need ASP 2.0 Client Side Callback Advice

Posted on 2006-06-22
4
Medium Priority
?
1,379 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 Ageil
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 Ageil earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Loops Section Overview
Suggested Courses

916 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