Showing posts with label updatepanels. Show all posts
Showing posts with label updatepanels. Show all posts

Wednesday, March 28, 2012

Programatically add UserControls that Contain an UpdatePanel

In the release notes for the latest release it states that you can programatically add UpdatePanels now. I have a user control (ascx) that contains an UpdatePanel and a Timer to refresh the panel. When I add more than one of these controls to the page programatically the first refresh of one of the UpdatePanels blanks out all of the data in all of ascx controls. When I add the controls to the page in the aspx code everything works fine. I need to add them programatically since the number of them is configurable. I have the ScriptManager control on the page with partial refresh enabled. Is there something special I need to do when I add these controls programatically?

UserControl

<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true" Codebehind="DataPart.ascx.cs" Inherits="MS.Support.KnowledgeManagement.VisualKb.DataPart"
EnableViewState="false" %>
<div class="dataPart">
<div id="divHeader" class="dataPartHeader" runat="server">
<img alt="Collapse" style='float: right' src='images/Collapse.gif' title='Collapse'
onclick="ExpandCollapse(this,this.parentElement.parentElement.children(1))" />
<asp:Label ID="lblHeader" runat="server"></asp:Label>
</div>
<div id="divBody" class="dataPartBody" runat="server">
<asp:UpdatePanel ID="divUpdate" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<vkb:VkbBulletedList ID="blItems" runat="server" BulletStyle='disc' DisplayMode='HyperLink'
CssClass="dataPartList" NewIndicatorFontColor="red">
</vkb:VkbBulletedList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timerRefresh" />
</Triggers>
</asp:UpdatePanel>
<div style='text-align: center; width: 100%'>
<asp:HyperLink ID="lnkViewAll" runat="server" CssClass="dataPartLink">View All</asp:HyperLink>
</div>
</div>
</div>
<asp:XmlDataSource ID="xmlDataSource" runat="server" XPath="descendant::Items/Item"
EnableCaching="false" EnableViewState="False"></asp:XmlDataSource>
<asp:Timer ID="timerRefresh" OnTick="timerRefresh_Tick" runat="server">
</asp:Timer>

Code to add ascx to page

dp = Page.LoadControl("DataPart.ascx") as DataPart;
dp.DataType = "Article";
dp.HeaderColor = Color.LightGray;
dp.HeaderFontColor = Color.Black;
dp.HeaderText = nodes.Current.GetAttribute("Name", String.Empty);
dp.CategoryId = Convert.ToInt32(nodes.Current.GetAttribute("Id", String.Empty));
dp.BodyColor = Color.WhiteSmoke;
dp.EnableRefresh = false;
dp.XmlData = nodes.Current.SelectSingleNode("Items") != null ? nodes.Current.SelectSingleNode("Items").OuterXml : "<Items />";
td.Controls.Add(dp);

I tried a simple example just using a RadioButtonList against XML data source and everything seemed to work fine when adding dynamically. What's in the VkbBulletedList control?
Its just an override of the BulletedList control to add some custom text to each bulleted item.

Wednesday, March 21, 2012

question about updateprogress control

Hi Everyone,

I'm building my first pages with AJAX. I have added a two updatepanels. One has the selections for my users searches, the other the viewgrids with the information they get back. It all works great. One option in for the viewgrids is to have the first column show as a link, and that brings back another smaller grid with the detail list for that selection they've clicked on. Works great -- brings back the info. I've added a updateprogress control to let them know the page is working when the click and it works great. Only problem I am having is that the updateprogress control is up above my main grid. If they are near the top, they see it, but if they are further down the page, they won't see it, plus they won't see the details grid when it is done building. Is there any way I can bounce them to the top of the report? Some sort of repositioning? How is this normally done?

thanks!

jekerry

You can try to use AlwaysVisibleControl, I think it will help you.

http://ajax.asp.net/ajaxtoolkit/AlwaysVisibleControl/AlwaysVisibleControl.aspx


That looks really good, only problem is that I am not sure how to get it added to my project! I have downloaded the toolkit to a folder on my harddrive, but have to admit I am not sure what do past that step.

thanks,

jekerry


Hello, please take a look athttp://ajax.asp.net/ajaxtoolkit/Walkthrough/Setup.aspx

Thank you! Just what I was looking for but somehow hadn't stumbled across.

jekerry

Question in regards to deploying AJAX enabled application to Windows 2003 server

I have developed an AJAX enabled web site on a Vista machine. The page I will be refering to contains ScriptManager, UpdatePanels and CollapsiblePanel. This page works fine on the local machine. However when I deployed this application to a Windows 2003 server (Framework 2.0 and ASP.NET 2.0 AJAX Extensions 1.0 installed) and try to invoke it, I get the following error. Any help will be appreciated.

--------
Windows Internet Explorer
--------
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near '<!DOCTYPE HTML PUBLI'.
--------
OK
--------

Are you using a Firewall on the server, I've seen issues with some firewalls and a setting "Remove Unknown Headers"

Check outhttp://alpascual.com/blog/al/archive/2007/04/26/How-to-fix-Sys.WebForms.PageRequestManagerParserErrorException-in-AJAX.aspx for a potential fix.

Also see this:http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx for help on debugging the issue.

-Damien

Question to the Ajax/ MS Team - UpdatePanels

There have been several posts that remained unresolved about why they were always getting FULL PostBacks after upgrading from RC versions to the Release Version. After reading the posts and doing a little testing - I discovered that merely dragging and dropping an UpdatePanel on a page - it defaults with UpdateMode = "Always".

That kinda does not make sense as the default should be towards the benefit of using Ajax - or in other words should always default to "Conditional" and I do believe that is a change between the RC and Release version.

The same goes for PageMethods - It should default to already enabled - like it did in the previous versions or at least on the docuementation site a left hand menu selection specifically for PageMethods - should annotate when clicked - PageMethods not enabled by default...

Alot of times as programmers while we may use the Designer mode - most of the times as we are building references do not popup to display all the defaults especially if there is an error on the page such as a missing /div tag etc...

But the main point it - strikes me odd from a usability standpoint why UpdateMode is defaulted to "Always"... I use VS Team Studio if that helps (and it has always had it quirks in the Ajax development scenarios...

None the less there mere fact it is defaulted to Always should be emphasized on the Docs site considering now everyone assumes that is the goto reference since it is no longer beta...

Hi,

the "Always" mode is not related with performing a full postback rather than a partial one. If an UpdatePanel has UpdateMode="Always", it will refresh its content even if the partial postback was triggered by a control that's not contained in the UpdatePanel, nor it's a trigger for that UpdatePanel.

If UpdateMode="Conditional", the UpdatePanel will refresh its content only if one of *its* children controls (if ChildrenAsTriggers="true") or triggers start the partial postback.


I believe that UpdateMode = "Always" has been the default since the Beta 1 release, and I don't think there was a default before that with the CTPs. I remember having to put it for every UpdatePanel. A large number of the posts I have come across about full postbacks have been from people who have not used the previous releases or are having validator issues. I have seen a few posts where people thought ajax worked differently, for example mistaking full postbacks with going to a whole new page. There are a lot of people that seem to have validator issues because they just are reading the conversion guide, not the blogs or other information about the validator change in the RTM, so they don't know they have a problem with validators.