PC Review


Reply
Thread Tools Rate Thread

What Clientside Event can I capture upon Callback completion?

 
 
John Kotuby
Guest
Posts: n/a
 
      28th Feb 2008
Hi all,

I am converting an ASPX 3.5 page in VB and VS 2008 from the standard
postback to callbacks using an UpdatePanel.
I had originally been adding an onload attribute to the Body tag in the
Master Page, which would call a Javascript function to display a message if
a hidden field contained a value other than a null string.

Well, of course I discovered that the Body onload event only happenned upon
initial load of the page.

I tried adding a client event attribute to the UpdatePanel but I am not
having any success.

Thanks for any help in this matter.



 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      28th Feb 2008
use ScriptManger.RegisterStartupScript(). it must be attached to a control in
update panel. also unless the hidden field is in the update panel, it will
not be updated with a async postback

-- bruce (sqlwork.com)


"John Kotuby" wrote:

> Hi all,
>
> I am converting an ASPX 3.5 page in VB and VS 2008 from the standard
> postback to callbacks using an UpdatePanel.
> I had originally been adding an onload attribute to the Body tag in the
> Master Page, which would call a Javascript function to display a message if
> a hidden field contained a value other than a null string.
>
> Well, of course I discovered that the Body onload event only happenned upon
> initial load of the page.
>
> I tried adding a client event attribute to the UpdatePanel but I am not
> having any success.
>
> Thanks for any help in this matter.
>
>
>
>

 
Reply With Quote
 
John Kotuby
Guest
Posts: n/a
 
      29th Feb 2008
Thanks for the tips Bruce.

Wow! I hadn't considered the fact that hidden fields outside of the update
panel would not be updated. I usually place my hidden fields near the bottom
of the page and in this case below the update panel.

You just saved me a whole bunch of time trying to track down the "bug" I
would eventually discover.

Thanks again...



"bruce barker" <(E-Mail Removed)> wrote in message
news68B8A95-CEE0-4B0D-8DC5-(E-Mail Removed)...
> use ScriptManger.RegisterStartupScript(). it must be attached to a control
> in
> update panel. also unless the hidden field is in the update panel, it will
> not be updated with a async postback
>
> -- bruce (sqlwork.com)
>
>
> "John Kotuby" wrote:
>
>> Hi all,
>>
>> I am converting an ASPX 3.5 page in VB and VS 2008 from the standard
>> postback to callbacks using an UpdatePanel.
>> I had originally been adding an onload attribute to the Body tag in the
>> Master Page, which would call a Javascript function to display a message
>> if
>> a hidden field contained a value other than a null string.
>>
>> Well, of course I discovered that the Body onload event only happenned
>> upon
>> initial load of the page.
>>
>> I tried adding a client event attribute to the UpdatePanel but I am not
>> having any success.
>>
>> Thanks for any help in this matter.
>>
>>
>>
>>


 
Reply With Quote
 
John Kotuby
Guest
Posts: n/a
 
      29th Feb 2008
Hi Bruce...

I found that the best way to ensure your suggested method to work was to
reference the UpdatePanel control itself and call the method statically as
in:

System.Web.UI.ScriptManager.RegisterStartupScript(Me.UpdatePanel1,
Me.UpdatePanel1.GetType(), "jsShowModal", "PageSetup(); ", True)

This worked fine but resulted in my dialog box popping up before the
contents of the UpdatePanel were completely refreshed.

In a forum discussion from 2006 when VS 2008 was in Beta I found this
alternate method to be used in the ASPX page:
----------------------------
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args)
{
showDialog("From PageRequestManager");
}
---------------------------
http://forums.asp.net/p/1037531/1440930.aspx

This approach allows the dialog to appear after the update panel contents
are completely refreshed. I cant really see a downside to this appoach
because the code always resides on the rendered page. Maybe there is a
problem that I might run into at some point and I will go back to the
System.Web.UI.ScriptManager.RegisterStartupScript. I was wondering if the
StartupScript that is produced actually persists after the first call to
RegisterStartupScript, or if that script is only generated on the page
whenever the method is called from the code-behind. I suppose that is easy
enough to test.

I was also wondering if I called ScriptManager.RegisterStartupScript in the
PreRender event or even later, if the contents of the Update Panel would be
rendered before the dialog appears.

Thanks for your help Bruce.

"bruce barker" <(E-Mail Removed)> wrote in message
news68B8A95-CEE0-4B0D-8DC5-(E-Mail Removed)...
> use ScriptManger.RegisterStartupScript(). it must be attached to a control
> in
> update panel. also unless the hidden field is in the update panel, it will
> not be updated with a async postback
>
> -- bruce (sqlwork.com)
>
>
> "John Kotuby" wrote:
>
>> Hi all,
>>
>> I am converting an ASPX 3.5 page in VB and VS 2008 from the standard
>> postback to callbacks using an UpdatePanel.
>> I had originally been adding an onload attribute to the Body tag in the
>> Master Page, which would call a Javascript function to display a message
>> if
>> a hidden field contained a value other than a null string.
>>
>> Well, of course I discovered that the Body onload event only happenned
>> upon
>> initial load of the page.
>>
>> I tried adding a client event attribute to the UpdatePanel but I am not
>> having any success.
>>
>> Thanks for any help in this matter.
>>
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to trap PageIndexChanged event at clientside =?Utf-8?B?QUJO?= Microsoft ASP .NET 0 10th Oct 2006 05:39 PM
Async Delegates completion callback Brett Robichaud Microsoft C# .NET 4 6th Oct 2004 06:30 PM
Datagrid link button click event in clientside Niclas Lindblom Microsoft ASP .NET 1 27th Jun 2004 04:24 AM
ClientSide event processing loading data anonymous Microsoft ASP .NET 0 5th Jan 2004 06:47 PM
calling clientside js with onchange event Zeebra3 Microsoft ASP .NET 4 8th Aug 2003 01:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:54 PM.