Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

What Clientside Event can I capture upon Callback completion?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Kotuby - 28 Feb 2008 23:07 GMT
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.
bruce barker - 28 Feb 2008 23:42 GMT
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)

> Hi all,
>
[quoted text clipped - 11 lines]
>
> Thanks for any help in this matter.
John Kotuby - 29 Feb 2008 00:59 GMT
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...

> use ScriptManger.RegisterStartupScript(). it must be attached to a control
> in
[quoted text clipped - 20 lines]
>>
>> Thanks for any help in this matter.
John Kotuby - 29 Feb 2008 15:20 GMT
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.

> use ScriptManger.RegisterStartupScript(). it must be attached to a control
> in
[quoted text clipped - 20 lines]
>>
>> Thanks for any help in this matter.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.