Wednesday, March 28, 2012

UpdateProgress.FindControl() does not work in beta 2

We have upgraded to beta 2 and the following code (which worked under beta 1) does not work.

The FindControl() method is returning null and the UpdateProgress.Controls.Count property is showing as 0.

Is this a problem in beta 2? Can anyone help with a solution?

<asp:UpdateProgressID="atlasProgress"runat="server">

<ProgressTemplate><asp:LabelID="messageLabel"runat="server"Text="Original Message"></asp:Label></ProgressTemplate></asp:UpdateProgress>

Label updateLabel = (Label)this.atlasProgress.FindControl("messageLabel");if (!(updateLabel ==null))

{

updateLabel.Text = "New Message";

}

I tested your codes and found the same problems as yours.asp:UpdateProgress.FindControl can not work in Ajax Beta 2.Maybe this is caused by Ajax Beta 2 framework.

Here are some explanations from ASP.NET Team for your reference.

Summary:

Due to a known issue with ASP.NET AJAX Beta 1, you may find that Extender controls no longer work with templated controls such as GridView or FormView. This issue will be addressed in the next release of ASP.NET AJAX.

Background:

The ScriptManager component on your ASPX page is responsible for rendering out the client script (JavaScript) that creates the client side components. The ScriptManager walks the list of components that need these hookups during it's PreRender phase of the page lifecycle. Unfortunately, templated controls often create their inner control heirarchies during PreRender as well. Therefore, since the ScriptManager appears earlier in the page than the templated control, the extenders have not been created yet, and the hookups don't happen.

Workaround:

Fortuantely, for the common case, there is a simple workaround. You simply need to force control generation earlier in the page lifecycle. The simplest way to do this is to call DataBind method or Controls property from the Page_Load.

protected void Page_Load(object sender, EventArgs e)

{

GridView1.DataBind(); // for databound controls

object o = Login1.Controls; // for templated controls

}

Caveat:

This doesn't work for templated controls that make changes to their tree, such as a GridView with an EditItemTemplate in it. If you have that scenario, unfortunately, you'll need to wait for the next release of ASP.NET AJAX Beta 1 to enable it.

Wish the above can help you.


Hi I'm having the same problem with the AjaxControlToolkit

Dim temp_lkExportedCSV As HyperLink = CType(UpdateProgress1.FindControl("lkExportedCSV"), HyperLink)
Dim temp_lblPercent As Label = CType(UpdateProgress1.FindControl("lblPercent"), Label)
Dim temp_lblStatus As Label = CType(UpdateProgress1.FindControl("lblStatus"), Label)

temp_lkExportedCSV.Enabled = False | And here I get an exception, because no control was found.


And I called the Controls method in the page load just like it was explained bu tit still didn't work.

Dim o As Object = Me.UpdateProgress1.Controls

Am I doing something wrong?


Maybe it's the nature of the UpdateProgress that's looks invisible until the associated UpdatePanel is updating.


This is a known issue with the UpdateProgress control. It gets added very late in the page's lifecycle. Move your code to the Page_PreRenderComplete event or Page_Unload event. Page_Load is too early.

No comments:

Post a Comment