I am using update panel and update progress control. In update panel I have textbox with TextChange event. This event is automatically called from javascript when user enters 10 digits into textbox. The call is :
__doPostBack("LabelTextBoxCode", "TextChanged");
This is my html code :
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress runat="server" ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel">
<ProgressTemplate>
...processing
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="LabelTextBoxCode" runat="server" OnTextChanged="TextChanged_TextBoxCode">
</asp:TextBox>
...
</ContentTemplate>
</asp:UpdatePanel>
So far what I found is this thread UpdateProgress Not working when called thru javascript but it does not help me (I do not know how to use it right in my case).
When I press any button in update panel, progress bar is showing, problem is just with this manually called __doPostBack from javascript.
How to fix it and make updateProgress works ?
Directly calling __doPostback bypasses all the triggers that set the update panel in action. So to avoid that you can either call the OnBeginRequest handler or you can trigger the same button click instead of calling the __dopostback. To trigger button click you can make use of jquery trigger function. You can get an example here.
Hope this helps.
Related
I just recently started to use the UpdatePanel and do not understand if what I get is standard behavior:
With an Update Panel defined like this...
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"/>
<asp:UpdatePanel runat="server" ID="UpdatePanel_Repeater" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Repeater ...
</ContentTemplate>
</asp:UpdatePanel>
is it normal that the panel gets updated after a Postback caused by a control (DropDownList - SelectedIndexChanged) that isn't inside any UpdatePanel?
I want this to be updated only if called explicitly by UpdatePanel_Repeater.Update() or on PageLoad
I am working on an app that loads modules (which are just user controls) into a single update panel. UpdateMode="Always". There is an UpdateProgress control with a gif that should display on postback.
For a few modules, the UpdateProgress doesn't show until the second postback from the module. So for example, the one module has a dropdown that posts back on change. If the user changes the dropdown before doing anything else, there will be no indication (no progress gif) that it is posting back. If the user then changes the drop down again (or any other postback), the UpdateProgress shows. Any ideas?
I've verified that it isn't just the drop down control and the initial postback takes long enough that the progress gif should show. UpdatePanel code below, module user controls are loaded in cphMain.
I am currently working around this by doing a __doPostBack in JavaScript when the module loads, but this is ugly.
<asp:UpdatePanel ID="upMain" runat="Server" UpdateMode="Always">
<ContentTemplate>
<asp:UpdateProgress ID="uPrgMain" runat="server" AssociatedUpdatePanelID="upMain">
<ProgressTemplate>
<h4>
<asp:Image ID="imgLoading" runat="server" ImageUrl="~/images/loading.gif" AlternateText="Loading" />
Loading...</h4>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:ContentPlaceHolder ID="cphMain" runat="server">
</asp:ContentPlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
I have an update panel, an async trigger and a button outside the update panel. The button is wrapped with the trigger. All this is in one form. I load this form using the .load() method (jQuery). It works fine: I press the tab and the form loads into the other form. Then, when I press the button for the first time it fires the click event, but when I press it again nothing happens. Can you please help? I have tried putting the button in and out of the update panel and it's still not working. Here's my code:
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Search" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName = "Click"/>
</Triggers>
<ContentTemplate>
...
If you're loading the form with jquery it may be something where you need to rebind an event, I'm not familiar with the .load method()
I assume this section of code works fine if you pull it off into a test page?
Well, i have this in my master page
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" ScriptMode="Release" />
And this in a usercontrol
<asp:UpdateProgress ID="updateProgress1" runat="server" AssociatedUpdatePanelID="CustomerListUpdatePanel" DisplayAfter="0" DynamicLayout="false">
<ProgressTemplate>
<asp:Literal ID="loadingLiteral" runat="server" Text="<%$resources:Label,Loading %>" />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel id="CustomerListUpdatePanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SearchButton" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:repeater id="CustomerListRepeater" runat="server">
Problem here is that when i press the SearchButton the update panel updates but the UpdateProgress does not show it self, even if it takes a few seconds.. [somewhat solved by Yuriy Rozhovetskiy].
Problem is that the child buttons inside the updatepanel do not cause a total postback, instead they only reload the update panel, so it seems ChildrenAsTriggers="false" does not work or im miss understanding it.
Im using AjaxControlToolkit 4.1.50731.0.
Edit: also the UpdateProgress seems to display it self if a button is pressed inside the update panel...
Associating an UpdateProgress with an UpdatePanel Control:
The AssociatedUpdatePanelID property has the following effect on
UpdateProgress control behavior:
When the AssociatedUpdatePanelID property is not set, the
UpdateProgress control is displayed for the following postbacks:
Postbacks that originate from inside any UpdatePanel control.
Postbacks that originate from controls that are asynchronous
triggers for any UpdatePanel control.
When the AssociatedUpdatePanelID property is set to an UpdatePanel
control ID, the UpdateProgress control is displayed for postbacks
that originate from inside the associated UpdatePanel control.
Not sure about #Problem 1.
Regarding #Problem 2... I think your understanding might not be correct.
http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.childrenastriggers.aspx
I have a rather complex custom control - the custom control has a couple of update panels in it.
I am trying to use the control like this inside of an update panel:
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:Button ID="btn1" runat="server" Text="Sample Button" /> <asp:Label ID="lblTime" runat="server"></asp:Label>
<cc1:MyCustomControl ID="MyCustomControl1" runat="server" >
</cc1:MyCustomControl>
</ContentTemplate>
</asp:UpdatePanel>
When I click the button in the update panel, it does an async post back and there is no screen "flicker" When I click a button in my custom control the page flickers and does a full post back.
Inside the custom control, there are update panels that are trying to do full postbacks (based on triggers).
How can I make the page level UpdatePanel not do a full postback no matter what is going in inside of the custom control?
Have you thought about explicitly setting an asp:AsyncPostBackTrigger with the btn1 control in the up1 UpdatePanel control.
<asp:UpdatePanel ID="up1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn1" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button ID="btn1" runat="server" Text="Sample Button" />
<asp:Label ID="lblTime" runat="server"></asp:Label>
<cc1:MyCustomControl ID="MyCustomControl1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
Edit: How you tried to explicitly call the Update method in the button's OnClick event for the Update Panel? This includes the Update panels embedded within the custom control.
Figured out the solution similar issue to this: How can I get an UpdatePanel to intercept a CompositeControl's DropDownList
Except my control causing the postback was in an updatepanel with a full postback trigger. I was able to pull that control out so it was not nested with in update panels and that resolved it.
I would first look if there is some other issue with the custom control causing the full page postback, as in any case what should be happening is that the whole update panel refreshes (still with ajax).
After that, just look at the Nesting UpdatePanel Controls section of this:
http://msdn.microsoft.com/en-us/library/bb398867.aspx#
Also make sure to have the ScriptManager control with the property EnablePartialRendering set to true.
On the UpdatePanel, set the property ChildrenAsTriggers="true". This tells the UpdatePanel to intercept all PostBack invocations that originate from inside the UpdatePanel.
You may want to also explore the UpdateMode property, which determines what kinds of events trigger an update. (By default, an UpdatePanel will refresh if any other panel on the screen gets refreshed. This threw me for awhile until I realized what was going on.)