[Atlas Beta1] how to manually trigger an async postback

P

Patrick Ruzand

Hello,

I have developed a custom ASP.NET WebControl and I am now testing a possible
Atlas integration, to take advantage of the UpdatePanel partial refresh.

My WebControl subclass consists on a simple control that renders itself as
an <img> tag with an associated <imagemap>, the imagemap being used to
provide tooltips. Coupled with this img, it adds an OnClick event handler
that performs some hidden field initialization and then calls
myform.submit(). That's it for my control.

To test Atlas UpdatePanel features, I have added my control to the
ContentTemplate of an UpdatePanel. Unfortunately, with no success: when I
click on my image, the full page is loaded.
After some investigations, it happens that, from what I have understood, the
whole async postback mechanism relies on the form.onsubmit event. At least,
that's what I deduced from the PageRequestManager.OnFormSubmit event handler.
Which explains the problem I am facing: because calling form.submit does not
raise onsubmit event, the PageRequestManager.OnFormSubmit is never called
when I click on my image and the page is fully reloaded.

To be sure the problem came from here, I replaced the call to
'myform.submit' by:
PageRequestManager.getInstance()._onFormElementClick(a_Sys_UI_DomEvent);
PageRequestManager.getInstance()._onFormSubmit(a_Sys_UI_DomEvent);
and it works.

So, what is the proper methodology to trigger an async postback in such a
configuration ? Is there a way to manually trigger an onsubmit ?

(changing the <img> tag with an <input type="image"> and removing the
explicit call to 'myform.submit' is not a solution. In this configuration, it
works fine, but the problem is the imagemap is then lost (not taken into
account by thr browser with an 'input' image)).

Thanks a lot for your help,

Patrick
 
S

Steven Cheng[MSFT]

Hello Patrick,

From your description, I understand you want to integrate the ATALS
updatepanel feature into your custom web control.

Based on my understanding, updatepanel is one of the atlas component that
support partial rendering and updating, however, for custom web control's
development, you may have to consider the following things:

1When using ATLAS in asp.net application, you need to configure and deploy
the ATLAS package in the whole application rather than simply configure in
your control. Therefore ,your webcontrol will be retricted to ATLAS
application only.

Also, as you mentioned the following code snippet

==============
PageRequestManager.getInstance()._onFormElementClick(a_Sys_UI_DomEvent);
PageRequestManager.getInstance()._onFormSubmit(a_Sys_UI_DomEvent);
==============

Are you doing any customization on the updatepanel page's postback?

BTW, from the title, you're using the latest beta1 version of the
ATLAS(ASP.NET AJAX) package, correct?


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Patrick Ruzand

Hello Steven,
Hello Patrick,

From your description, I understand you want to integrate the ATALS
updatepanel feature into your custom web control.
Based on my understanding, updatepanel is one of the atlas component that
support partial rendering and updating, however, for custom web control's
development, you may have to consider the following things:

1When using ATLAS in asp.net application, you need to configure and deploy
the ATLAS package in the whole application rather than simply configure in
your control. Therefore ,your webcontrol will be retricted to ATLAS
application only.

In fact, I am investigating how our WebControl developped in ASP.NET 1.0
could be integrated into the UpdatePanel framework. My WebControl consists
on basically an image plus an imagemap that performs a submit when the
user click on the image.
My first thought was that it would take advantage of the UpdatePanel partial
refresh without modifying my WebControl, just by adding it to an
UpdatePanel's
ContentTemplate, something like that:
....
<asp:UpdatePanel id="updatepanel1">
<ContentTemplate>
<cc1:MyControl .../>
</ContentTemplate>
</asp:UpdatePanel>
....

But it did not work. Indeed, as I told you, my WebControl uses an onClick
event handler to perform some checking/initialization and then calls
form.submit()
explicitely to perform the postback. The problem is that this postback
seems not to be catched by the Atlas PageRequestManager class, the latter
listening the onsubmit event. Since form.submit() does not raise onsubmit
event,
my postback pass through the partial refresh mechanism, and the page is
fully reloaded.
But again this is my understanding, it may be totally wrong.
Also, as you mentioned the following code snippet

==============
PageRequestManager.getInstance()._onFormElementClick(a_Sys_UI_DomEvent);
PageRequestManager.getInstance()._onFormSubmit(a_Sys_UI_DomEvent);
==============

yes, this is the only workaround I found for the time being, calling
explicitely
the Atlas PageRequestManager's functions that are called by the
PageRequestManager's
onsubmit event handler.
In fact, another workaround is to use an <input type=image> instead of an
Are you doing any customization on the updatepanel page's postback?

When the user click on my control (the <img> in the rendered html), it posts
a form.submit(). In response to this submit, my webcontrol performs some
action on the server that may change the appearance of the control, and then
renders
a new said:
BTW, from the title, you're using the latest beta1 version of the
ATLAS(ASP.NET AJAX) package, correct?

Yes, that's correct.

Thanks,

Patrick
 
S

Steven Cheng[MSFT]

Thanks for your reply Patrick,

I'll have a look and perform some further research. I'll update you if I
get any new information.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Hi Patrick,

After some further investigation, I'm afraid so far I haven't found any
other better means on this. Does your current workaround fit the scenario,
if so, you can continue using it now. Also, I would suggest you post
request to the AJAX forum in WWW.ASP.NET site since there some web UI
team's engineer there.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Patrick Ruzand

Hi Patrick,
After some further investigation, I'm afraid so far I haven't found any
other better means on this. Does your current workaround fit the scenario,
if so, you can continue using it now. Also, I would suggest you post
request to the AJAX forum in WWW.ASP.NET site since there some web UI
team's engineer there.

Thanks Steven. I'll see whether the workaround I found might be
used in the final product.
Also, being currently in Barcelona for MS TechEd Developer, I'll
try to catch an Atlas engineer and see if there are other ways.

Thanks for your help,

Patrick
 
S

Steven Cheng[MSFT]

Hello Patrick,

Thanks for your reply.

If you get any further progress later, please feel free to post here so
that any other members and also reference to it.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Patrick Ruzand

Hello Patrick,
Thanks for your reply.

If you get any further progress later, please feel free to post here so
that any other members and also reference to it.

Thanks to the great Atlas team at TechEd, my problem is eventually solved.
Actually, the issue was that I was doing the submit in the old ways,
that is calling form.submit().
In ASP.NET, you should not call the submit() method because doing this,
you bypass the ASP postBack mechanism. Instead, you should
call the PostBack event handler reference.
In my case, the javascript code generation should be written as:
script.AppendFormat("\t\t"+Page.ClientScript.GetPostBackEventReference(this,
"")+";{0}", Environment.NewLine);

where 'script' is a StringBuffer containing the javascript code generated
by my WebControl.

And then all works fine.

Thanks,
Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top