Solved

Need ASP 2.0 Client Side Callback Advice

Posted on 2006-06-22
4
1,369 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
grab and show facebook pages event calendars 6 64
Runtime Error 2 27
Runtime Exceptions when trying to submit data 28 36
Split in Javascript 5 30
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

12 Experts available now in Live!

Get 1:1 Help Now