search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Can't get refreshCallBack() to work in ASP.NET 3.5

Asked by Jimmie Andersson
16 years ago.
Hello, I've recently upgraded my web from asp.net 2.0 to .net 3.5 and ran into one thing with the refreshCallBack function. I've been testing the exact same code in .net 2.0 and .net 3.5 projects now and confirmed that the problem must have something with the new framework to do.

Below is links to show my code:
Cal.aspx code
Cal.aspx.cs code

When I call refreshCallBack() from the <a href> tags onclick attribute it works fine!
But when I click the button inside the update panel and from the server method tries to trigger the refreshCallBack() method, it doesn't work anymore (Line 42 in Cal.aspx.cs)

As I said before, this works fine in .net 2.0 but stopped working in .net 3.5.
I use the latest 4.6 version of daypilot.

Any suggestions?
Comment posted by Dan Letecky
16 years ago.
I would try the following:

<asp:Button ID="btnAdd" runat="server" OnClientClick="javascript:dpc1.refreshCallBack(-7);" Text="This refresh should work" />

Let me know if it didn't help.
Comment posted by Jimmie Andersson
16 years ago.
Yes, that worked, but it doesn't solve my problem. I need to be able to call the refresh function from server side.
Like it worked before I upgraded to 3.5
Comment posted by Dan Letecky
16 years ago.
OK, I'll give it a try.
Comment posted by Jimmie Andersson
16 years ago.
Thank you very much!
Comment posted by Dan Letecky
16 years ago.
I've found out that calling CallBack from within the async postback was explicitly forbidden in .NET Framework 3.5. See line 486 in MicrosoftAjaxWebForms.js:

// DevDiv Bugs 125825: Do not allow callbacks to begin while an async postback is in progress to prevent EVENTVALIDATION corruption
if (!this.get_isInAsyncPostBack()) {
this._originalDoCallback(eventTarget, eventArgument, eventCallback, context, errorCallback, useAsync);
}
Comment posted by Jimmie Andersson
16 years ago.
okey thank you, But I really dont understand what they explicitly forbidden in .NET Framework 3.5.
Do you have any suggestion on how to make a workaround?

I need to change date and update the calender from server-side.
One solution I tryed before is to use postback and put the whole calender inside a update panel but I found that very slow and the client side way, calendar.refreshCallBack() is much faster!
Comment posted by Dan Letecky
16 years ago.
It seems that partial PostBack flag is cleared after all scripts embedded in the partial PostBack are executed. And because you embed a refreshCallBack call (which calls WebForm_DoCallBack) it is denied because the partial PostBack is still in progress.

I would try delaying the refreshCallBack a little bit (but I haven't tried it):

ScriptManager.RegisterClientScriptBlock(uplTemp, this.GetType(), "refresh", "javascript:window.setTimeout('dpc1.refreshCallBack(-7)', 100);", true);

The other options depend on why you need to call the refreshCallBack from the server-side code. Can you describe your use case a little bit?
Comment posted by Jimmie Andersson
16 years ago.
Oh the window.setTimeout worked great! you made my day :)
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.