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 / September 2007

Tip: Looking for answers? Try searching our database.

AJAX - How to set the Text of a Literal control outside of the UpdatePanel?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alan Silver - 05 Sep 2007 17:47 GMT
Hello,

I have just started using AJAX today, and I'm amazed at how easy it is!

Anyway, excitement aside, I have managed to convert an existing order
page to show the order total as the user changes values on the form
(quantity of items, delivery country, etc), and have an order summary,
which uses Literal controls to display the results.

The problem is that I would like the order summary information to be
outside of the UpdatePanel so it is further down the page, below the
Order button (asp:Button control) that submits the whole page. However,
if I move the Literal controls outside of the UpdatePanel, they don't
get updated by the AJAX code.

I can see two ways out of this, but I don't know how to do either!

1) Put the summary Literal controls in a second UpdatePanel, and set the
code to update that panel as well as the first.

2) Extend the existing UpdatePanel further down the page, but set the
Order button to do a normal page postback, not an AJAX one.

I don't know if either of these can be done, or how. Any help would be
greatly appreciated. TIA.

Signature

Alan Silver
(anything added below this line is nothing to do with me)

Alan Silver - 05 Sep 2007 19:58 GMT
>1) Put the summary Literal controls in a second UpdatePanel, and set
>the code to update that panel as well as the first.

OK, figured this out in case it's useful to anyone else. I made a second
UpdatePanel, and added a trigger for one of the controls that fires the
AJAX calls. The second panel looks like this...

<asp:UpdatePanel ID="updOrderSummary" runat="server">
<ContentTemplate>
...Literal controls go here...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="drpCountry" />
</Triggers>
</asp:UpdatePanel>

What I don't understand is why I only needed to add a trigger for the
one control, when the AJAX call is triggered by any one of a number of
controls on the page. It seems to worth though!

Anyone able to explain this last bit? TIA

Signature

Alan Silver
(anything added below this line is nothing to do with me)

Göran Andersson - 05 Sep 2007 20:37 GMT
>> 1) Put the summary Literal controls in a second UpdatePanel, and set
>> the code to update that panel as well as the first.
[quoted text clipped - 17 lines]
>
> Anyone able to explain this last bit? TIA

I don't think that you need any trigger at all. The UpdateMode of the
update panels is set to Always by default, which means that every update
panel on the page will be updated with every AJAX postback.

If you set the UpdateMode to Conditional, the udpate panel will only be
updated when there is a matching trigger, or if you call the Update
method for the update panel.

Signature

Göran Andersson
_____
http://www.guffa.com

Alan Silver - 06 Sep 2007 14:12 GMT
>>  What I don't understand is why I only needed to add a trigger for
>>the one control, when the AJAX call is triggered by any one of a
[quoted text clipped - 4 lines]
>update panels is set to Always by default, which means that every
>update panel on the page will be updated with every AJAX postback.

Ah, that explains why it worked when I had only added one trigger.

Thanks for the clarification. I must say that I found AJAX amazingly
easy to get going, but obviously I am far from understanding all the
details yet.

Signature

Alan Silver
(anything added below this line is nothing to do with me)


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.