Wednesday, March 21, 2012

Question about UpdatePanel

Hi !

I have a user control with an objectDataSource and a dropDownList. These controls are inside a user control because they will be reused in some pages.

This user control has a property that returns the selectedValue of the combo.

So, in one page I add the usercontrol, another objectdatasource and a gridview. The property in the first user control is a parameter for the 2nd objectDataSource.

So, I would like to eliminate the postback when I change the 1st combo. I tried to put the 2nd ObjectDataSource and the gridview inside an UpdatePanel and create a Triger linking with the user control property, but it fails, the gridview doesn't appears.

I tried some other combinations to, and nothing works.

So : how to use a web user control to trigger an UpdatePanel ?

The UpdatePanel identifies some properties of the controls, just some. Why ? What can I do to get my property in user control recognized by UpdatePanel triggers ?

Thanks!

P.S. : Sorry by my English, I don't speak English well.

[]'s

Dennes

Hi Dennes,

Although Visual Studio doesn't show custom properties on UserControls (it's a technical limitation in VS2005), you should be able to type it in manually in source view. At runtime it should all just work.

Thanks,

Eilon


Hi !

I already tried this, but doesn't work. I think It's because I'm using a web user control, trying to make a trigger point to a custom property in web user control. I think I need to do something more, but don't know exactly what.

Just pointing the trigger to the property doesn't work.

[]'s

Dennes


Hi Dennes, can you show me a sample that reproduces this problem?

Thanks,

Eilon


Hi, Eilon !

Here, the user control :

PartialClass usrComboInherits System.Web.UI.UserControlPublic ReadOnly Property Categoria()As Integer Get If ddlCategorias.SelectedValue <>""Then Return (ddlCategorias.SelectedValue)Else Return (Nothing)End If End Get End PropertyEnd Class

<%@. Control Language="VB" AutoEventWireup="false" CodeFile="usrCombo.ascx.vb" Inherits="usrCombo" %><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString%>" SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:SqlDataSource><asp:DropDownList ID="ddlCategorias" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID"></asp:DropDownList>

The page, default.aspx :

<%@. Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@. Register src="http://pics.10026.com/?src=usrCombo.ascx" TagName="usrCombo" TagPrefix="uc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" /> <uc1:usrCombo ID="UsrCombo1" runat="server" /> <br /> <atlas:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString%>" SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [UnitsInStock] FROM [Products] WHERE ([CategoryID] = @.CategoryID)"> <SelectParameters> <asp:ControlParameter ControlID="UsrCombo1" Name="CategoryID" PropertyName="Categoria" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="ProductID" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="None"> <FooterStyle BackColor="Tan" /> <Columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False" ReadOnly="True" SortExpression="ProductID" /> <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" /> <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" /> <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" /> </Columns> <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" /> <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" /> <HeaderStyle BackColor="Tan" Font-Bold="True" /> <AlternatingRowStyle BackColor="PaleGoldenrod" /> </asp:GridView> </ContentTemplate> <Triggers> <atlas:ControlValueTrigger ControlID="UsrCombo1" PropertyName="Categoria" /> </Triggers> </atlas:UpdatePanel> <br />   </form></body></html>

In this case, the postback still happens, the trigger is ignored. This same sample with a dropdownlist instead the user control works fine, the user control is the problem

So, I tried again, with the combo inside the UpdatePanel and no triggers. I get surprised, because it worked, but in my website It doesn't.

So, I couldn't reproduce the complete problem, just one part. My webpage is more complicated, it uses objectDataSource, call webservices and uses a customParameter (ReflectionParameter), uses a masterPage with other user controls in other parts of the complete page. One of these caused the problem with atlas, I'm still trying to discover.

My last try resulted in the following message :

Error : 'Sys.Application.findObject(...)' is null or not an object

[]'s

Dennes

No comments:

Post a Comment