Showing posts with label updateprogress. Show all posts
Showing posts with label updateprogress. Show all posts

Wednesday, March 28, 2012

Multiple updatepanels and updateprogress

Hi,

I have created two updatepanels with a button and a label in each panel. Both panels are associated to a updateprogress. When I click the button I simle add datetime.now to the label. I also use thread.sleep for some seconds. This is a basic asp.net ajax example. But my question is: when I click the first button and thereafter click the second button when the first one is at sleep. In this case the second updateprogress starts working and I get the date in the second label. How can I manage to implement two asynchronous calls at the same time? i.e. I want to press both buttons and get two dates in each label.

You can't execute two partial postbacks simultaneously.

In InitializeRequest, you can use PageRequestManager.get_isInAsyncPostBack() to test for an already running partial postback and respond accordingly.


Ok, thank you. My question is answered!

Multiple UpdateProgress on a page?

My UpdateProgress Panel gets fired when I use my modalpopup box. Is there anyway for the modal popup to have its own progress and not trigger the one already defined on the page?

If you define aasp:UpdateProgressin a web form and specify an AssociatedUpdatePanelID?property for it, it will be triggered?and?display?the?
AssociatedUpdatePanel when you press any control in the web form.
Try the following codes and check if it works in your project.
<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
var postBackElement;
function InitializeRequest(sender, args) {
if (prm.get_isInAsyncPostBack())
{
args.set_cancel(true);
}
postBackElement = args.get_postBackElement();
if (postBackElement.id == 'ButtonTrigger')
{
$get('UpdateProgress1').style.display = "block";
$get('ButtonTrigger').style.display = "none";
}
}
function EndRequest (sender, args) {
if (postBackElement.id == 'ButtonTrigger')
{
$get('UpdateProgress1').style.display = "none";
$get('ButtonTrigger').style.display = "block";
}
}
function AbortPostBack() {
if (prm.get_isInAsyncPostBack()) {
prm.abortPostBack();
}
}
</script
<div>
<asp:Button ID="ButtonTrigger" runat="server" Text="Refresh Panel 5" OnClick="Button_Click" />
<asp:UpdatePanel ID="UpdatePanel5" runat="server">
<ContentTemplate>
<%=DateTime.Now.ToString() %> <br />
The trigger for this panel
causes the UpdateProgress to be displayed
even though the UpdateProgress is associated
with panel 2.
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ButtonTrigger" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel6" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<%=DateTime.Now.ToString() %> <br />
<asp:Button ID="Button2" runat="server" Text="Refresh Panel 6" OnClick="Button_Click"/>
</ContentTemplate>
</asp:UpdatePanel>
<span style="display: inline-block;">
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/airplane.bmp" />
</ProgressTemplate>
</asp:UpdateProgress>
</span>
</div>
Wish the above can help you.

Multiple UpdateProgress controls not possible?

Hi,

I'm currently learning ASP.NET AJAX. I wanted to play around with the different settings of the DynamicLayout property of the UpdateProgress control. I dragged from the toolbox a scriptmanager, updatepanel and 2 updateprogress controls on the same page.

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="UpdateProgress2.aspx.cs" Inherits="UpdateProgress2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress1" runat="server"> </asp:UpdateProgress> <asp:UpdateProgress ID="UpdateProgress2" runat="server"> </asp:UpdateProgress> </form></body></html>

However this results for the second updateprogress control into this error message:Duplicate component name "UpdateProgress2". Component names must be unique and case-insensitive. Am I trying something stupid/not allowed?

Grz, Kris.

Does the error go away if you change the ID of the second UpdateProgress? I notice that your codebehind class happens to be called "UpdateProgress2" as well, and that's not allowed.

I get a different error message for that, though: "member names cannot be the same as their enclosing type," so it's possible that's not the same error you're seeing.


Hi,

thanks! Renaming solved it. Man, I told you I was probably doing something stupidEmbarrassed. I was so focussed on learning the new stuff that I missed that one.

Grz, Kris.

Multiple UpdateProgress Controls

Hi,

Does anyone know if there are plans to allow for multiple UpdateProgress controls in a future release of Atlas? This is an important requirement for most Ajax sites as activity indicators are usually located near the control that triggered the postback.

I have seen a workaround that allows you to do it using a combination of JS and CSS but it would be great if this was automatically available in the framework.

Cheers,

Jason

Do it easily using bindings in the aspx code :

<div id="myProgressUdpate1" >Data Loading</div>
<div id="myProgressUdpate2" >Data Loading</div
<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<components>
<control id="myProgressUdpate1">
<bindings>
<binding dataContext="_PageRequestManager" dataPath="inPostBack" property="visible" />
</bindings>
</control>
<control id="myProgressUdpate2">
<bindings>
<binding dataContext="_PageRequestManager" dataPath="inPostBack" property="visible" />
</bindings>
</control>
</components>
</page>
</script>

hello.

hum...i think he wanted a solution where only one updatepanel would be show. i think that currently this won't be possible (ie, writting generic code that works in all cases) because you can't get a reference to the updatepanel that is "responsible" for the download.

if the team changes the pagerequestmanager class slightly so that it let us access the posback settings, it would be easy to get that info...


Yes, I do only want one of the updateprogress controls to show depending on the control that triggered the postback. Maybe the UpdateProgress control could be enhanced to allow triggers to be assigned in a similar way to UpdatePanels so that they only show when certain events or conditions occur.
Does anyone from MS have a comment on this one...this is a must-have feature for most AJAX apps?
I would agree, I just tried to accomplish this and without doing a lot of fancy javascript to figure out where the user clicked and show it in the right spot based on what and where things were clicked on I couldn't get it to work. Sure would be nice if UpdateProgress controls could be bound to UpdatePanel controls.

Note this is a supported scenario since ASP.NET AJAX beta 1 with "Value-Add" CTP:
You can have multiple UpdateProgress controls on a page that can run conditionally based on which UpdatePanel callback is occurring.


Thanks...I noticed this in the release notes and it is an excellent enhancement.


Would be even better if we could attach an UpdateProgress to multiple UpdatePanel...!

AssociatedUpdatePanelID="updatePanel1, updatePanel2"


Some people are just never happy ;-)

You're right though...that would be a useful extension to save duplicating the UpdateProgress controls. I can think of at least one case where I could use that although I will probably just locate an UpdateProgress control in "neutral" territory.


Why not make your lives easier and put your UpdateProgress into a UserControl that you can just drag and drop in? Works a LOT easier IMO.

Pluginbaby:

Note this is a supported scenario since ASP.NET AJAX beta 1 with "Value-Add" CTP:
You can have multiple UpdateProgress controls on a page that can run conditionally based on which UpdatePanel callback is occurring.

has anyone actually gotten this to work with either the beta 1 or beta 2 release? when i specify a value for the AssociatedUpdatePanelID property, the UpdateProgress control never appears.

thanks


Yeah...it is working for me in beta 1 although I do have to use the ClientID of the UpdatePanel control rather than just its ID, so if you are using MasterPages, it will look something like "ctl00_ContentPlaceHolder_UpdatePanel". I am therefore setting the AssociatedUpdatePanelID in the Page_Load event using UpdatePanel.ClientID so that I don't have to worry about any changes in the control hierarchy.

I had a number of problems with beta 2 and had to rollback to beta 1 so not sure if the above is the same for beta 2.

Cheers,

Jason


I made a very simple test to try out UpdateProgress in Beta 2.

There'a a Master Page with a ScriptManager on it.

A Content Page that looks like this

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>   <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="False"> <ProgressTemplate>loading...</ProgressTemplate> </asp:UpdateProgress> <br />   <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate>  <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2" DynamicLayout="False"> <ProgressTemplate>loading...</ProgressTemplate> </asp:UpdateProgress>
Code is:
 
protected static int i = 0;protected void Page_Load(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToLongTimeString(); System.Threading.Thread.CurrentThread.Join(1000); }protected void Button2_Click(object sender, EventArgs e) { i++; Label2.Text = i.ToString(); System.Threading.Thread.CurrentThread.Join(1000); }

It's just two buttons and two labels. The first one displays the date, the second one increases a counter. Both have an UpdatePanel and UpdateProgress. The first UpdatePanel has a trigger event, which is the Button1's click. The second UpdatePanel has both the Button2 and Label2 inside it.

The first UpdateProgress does NOT work. The second one does. I didn't have to use ClientID or Unique ID, even though I'm using Master Pages. The problem, as far as I can see, is when the UpdatePanel has a trigger.


That still does not work for me - using beta 2. I have a page (that uses a masterpage), with two web user controls, each with their own updatepanel and updateprogress controls. when i try to specify the AssociatedUpdatePanelID in either user control in the Page_Load i get the following error:

No UpdatePanel found for AssociatedUpdatePanelID 'ctl00_ContentPlaceHolder1_Weather1_WeatherUpdatePanel'

I also tried to just create a simple page (w/o using a masterpage) with 2 updatepanels, 2 updateprogress controls and 2 buttons. when i specify the AssociatedUpdatePanelID in Page_Load on this page, there is no error message, but neither UpdateProgress control is never displayed either. If I don't specify the AssociatedUpdatePanelID, then both UpdateProgress controls appear.

If anyone else has any thoughts, I'd appreciate it. I can also post code, if desired.

Thanks

Wednesday, March 21, 2012

Need help in UpdateProgress Control inside ModalPopup Control

Hi All,

I need to show the progress control inside ModalPopup Control. Everytime I hit the button, the modalpopup should show the progress while the background code of the button is working. Modalpopup dialog show disappear when the background executing is done. For modalpopup control I set the targetcontrolID as the ID of the button.

When I click the button, the modalpopup dialog show up. But it doesn't trigger the background code of the button. Do I miss anything?
Thank you.

Fred

Hi,

What you need is keeping the modalpopup showing when the background executing is done.

So see:

http://forums.asp.net/t/1134216.aspx

http://forums.asp.net/t/1134520.aspx

These are what you need.

Best Regards,