Showing posts with label ctp. Show all posts
Showing posts with label ctp. Show all posts

Wednesday, March 28, 2012

Multiple UpdatePanels updated by single trigger -- bug or feature?

Hi, not sure if this has been discussed before but..

I'm running April CTP, and I have two UpdatePanels on my page. UpdatePanel1 includes a navbar with various LinkButtons, and the other UpdatePanel2 contains a GridView. I've added a ControlEventTrigger to UpdatePanel2 for the click event of the LinkButtons in UpdatePanel1. UpdatePanel1 has no triggers (I plan on adding triggers at a later time). The issue is, when I click a LinkButton from UpdatePanel1, it updates both UpdatePanels! I would like it to only update UpdatePanel2 as I thought it should, but maybe I am just not understanding the way UpdatePanels work.

I'm thinking the fact that UpdatePanel2 is using a Control Event from UpdatePanel1, this might be the cause of these problems. When I moved the LinkButtons out of UpdatePanel2, UpdatePanel1 was no longer updated. I've included the source code for the two UpdatePanels:

<atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional"> <ContentTemplate> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td><asp:LinkButton CssClass="navlink_selected" ID="homeLinkT" runat="server" OnClick="link_Click" CommandName="home" CommandArgument="1" >home</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="aboutLinkT" runat="server" OnClick="link_Click" CommandName="about" CommandArgument="2" >about</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="resumeLinkT" runat="server" OnClick="link_Click" CommandName="resume" CommandArgument="3" >resume</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="projectsLinkT" runat="server" OnClick="link_Click" CommandName="projects" CommandArgument="4" >projects</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="forumLinkT" runat="server" OnClick="link_Click" CommandName="forum" CommandArgument="5" >forum</asp:LinkButton> <asp:LinkButton CssClass="navlink_unselected" ID="contactLinkT" runat="server" OnClick="link_Click" CommandName="contact" CommandArgument="6" >contact</asp:LinkButton> </td> <td style="width:80px"> <atlas:UpdateProgress ID="up1" runat="server"> <ProgressTemplate> <asp:Image ID="Image2" runat="server" ImageUrl="~/images/Hourglass_iconsm.gif"/> </ProgressTemplate> </atlas:UpdateProgress> </td> </tr> </table> </ContentTemplate> </atlas:UpdatePanel> <atlas:UpdatePanel runat="server" ID="UpdatePanel2" Mode="Conditional"> <ContentTemplate> <asp:HiddenField ID="page_id" runat="server" Value="1" /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="page_id" DataSourceID="ObjectDataSource1" ShowHeader="False" GridLines="None" AutoGenerateEditButton="false" > <Columns> <asp:TemplateField> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Height="100%" Text='<%# Bind("page_content")%>' TextMode="MultiLine" Width="600px" Rows="10"></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("page_content")%>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="page_id" HeaderText="page_id" ReadOnly="True" SortExpression="page_id" Visible="False" /> </Columns> </asp:GridView> </ContentTemplate> <Triggers> <atlas:ControlEventTrigger ControlID="homeLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="aboutLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="resumeLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="projectsLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="forumLinkT" EventName="Click" /> <atlas:ControlEventTrigger ControlID="contactLinkT" EventName="Click" /> </Triggers> </atlas:UpdatePanel>

Anyone have any ideas?

Thanks,

Matt

This is not a bug, but the intended result.

Clicking a server control that causes a postback (i.e. a link button or a normal button) when that server control is contained within the ContentTemplate of an UpdatePanel will cause that UpdatePanel to update even if it is not explicitly defined as a trigger. UpdatePanel1 is updating for this reason and UpdatePanel2 is updating because the control is defined as a triggering event.

Ah, thanks for the clarification Joel!

Matt


So is there a way for getting around this? If I have a menu of links and I want some to be loaded into one updatepanel and some into another. Is this even do-able?

Thanks.

multiple updatepanels, AsyncPostbackTrigger fails when referenced from more then 1 panel

Im using the latest Beta1, both core and CTP and toolkit, none of the old dll's exist on the system

Im not sure if the following issue is by design or if its a bug,


I have 3 updatepanels on the page, call them p1, p2 and p3 to make it easy to understand
first 2 panels contain a gridview, and a few other controls, p3 contains a couple of dropdowns and a linkbutton (lnk_insert)
when lnk_insert is clicked a new row gets added to gridview in p2 and the updatepanel forp2 contains the following trigger

<Triggers>
<asp:AsyncPostbackTrigger ControlID="lnk_insert" EventName="Click" />
</Triggers
the codebehind takes care of the database stuff and rebinds grid in p2, the page displays correctly and the trigger works fine so far, p2 gets updated
now the trouble - p1 contains a grid as well, whose data depends on grid in P2 (some summary info), the data gets prepared & returned correctly, (verified via debug) and is bound to grid via gridviewXXX.Databind,
p1 updatepanel contains the same

<Triggers>
<asp:AsyncPostbackTrigger ControlID="lnk_insert" EventName="Click" />
</Triggers
referencing the same link button, howeverp1does not update its contents,
different render modes in panel, and forced update of p1 via codebehind didnt help

no error messages come up, no javascript errors in browser either

which makes me think, is it possibly to reference the same control from 2 different updatepanels via asynctrigger ? or is one just overwriting the hooks to the other and thats why one of them doesnt trigger the refresh,

any tips ? thanks in advance

hello.

triggers can be associated with several panels. the following sample demonstrates that:

<%@. Page Language="C#" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" id="manager" />
<asp:UpdatePanel runat="server" ID="panel1" UpdateMode="Conditional">
<ContentTemplate>
<span>UpdatePanel 1: <%=DateTime.Now.ToString( ) %></span>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="bt" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

<asp:UpdatePanel runat="server" ID="panel2" UpdateMode="Conditional">
<ContentTemplate>
<span>UpdatePanel 2: <%=DateTime.Now.ToString( ) %></span>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="bt" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

<asp:UpdatePanel runat="server" ID="panel3" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<span>UpdatePanel 3: <%=DateTime.Now.ToString( ) %></span>
<asp:LinkButton runat="server" ID="bt" Text="Refresh" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

can you build a small sample that reproduces the problem you're having?


Thanks for the prompt response and code sample, I figured out the problem, (I glued my code into your sample app , which helped locate the problem - it was my fault)

one of the databind's was pointing to the wrong grid - the 3 updatepanels work together as expected and have 2 triggers each

very nice, the attached is the full page, - certainly it wont run without the codebehind, but thats quite lengthy

bottom line multiple updatepanel can have multiple triggers even if (some) of the triggers reference the same control - works fine

<Triggers>

<asp:AsyncPostBackTriggerControlID="bt"EventName="Click"/>

<asp:AsyncPostBackTriggerControlID="gv_group"EventName="SelectedIndexChanged"/>

</Triggers>

<%@.PageLanguage="vb"AutoEventWireup="false"CodeBehind="3updatepanels.aspx.vb"Inherits="schedule._3updatepanels"StylesheetTheme="Default" %>

<%@.RegisterSrc="../controls/nav_main.ascx"TagName="nav_main"TagPrefix="uc1" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<asp:ScriptManagerrunat="server"id="manager"/>

<uc1:nav_mainID="Nav_main1"runat="server"/>

<divclass="filter">

<tableborder=1cellspacing=1cellpadding=1width=100%align=center>

<tr>

<td><h2>Groups</h2></td>

<td>Group Name

<asp:TextBoxID="txt_groupname"runat="server"></asp:TextBox></td>

<td>Contains Resource

<asp:DropDownListID="dd_resource"runat="server"AppendDataBoundItems=TrueDataSourceID="dsrc_resourcenames"DataTextField="name"DataValueField="pk_resource">

<asp:ListItemText="All"Value="0"></asp:ListItem>

</asp:DropDownList></td>

<td> Total Items =

<asp:LabelID="lbl_numItems"runat="server"></asp:Label></td>

<td>

<asp:ImageButtonID="btn_refresh"runat="server"ImageUrl="~/images/loader_36.gif"/></td>

</tr>

</table>

</div>

<asp:UpdatePanelrunat="server"ID="panel1"UpdateMode="Conditional">

<ContentTemplate>

<span>UpdatePanel 1: <%=DateTime.Now.ToString( ) %></span>

<asp:GridViewID="gv_group"runat="server"AutoGenerateColumns="False"DataKeyNames="pk_groupname"

DataSourceID="ds_groups"SkinID="BlueSky"AllowSorting=True>

<Columns>

<asp:CommandFieldShowSelectButton="True"/>

<asp:BoundFieldDataField="name"HeaderText="Group Name"SortExpression="name"/>

<asp:BoundFieldDataField="NumItems"HeaderText="Number of Resources"ReadOnly="True"SortExpression="NumItems"ItemStyle-HorizontalAlign=Center/>

<asp:CommandFieldShowDeleteButton=TrueButtonType=ImageDeleteImageUrl="~/images/cancel.gif"ShowEditButton=TrueEditImageUrl="~/images/edit.gif"CancelImageUrl="~/images/cancel.gif"UpdateImageUrl="~/images/confirm_16.gif"/>

</Columns>

</asp:GridView>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="bt"EventName="Click"/>

<asp:AsyncPostBackTriggerControlID="gv_GroupResources"EventName="RowCommand"/>

</Triggers>

</asp:UpdatePanel>

<tablewidth="100%"cellpadding="0"cellspacing="1"bgcolor="gainsboro">

<tr>

<tdbgcolor="whitesmoke"height="25"><imgid="plusminus"src="../images/plus.gif"align="absMiddle"/>

<b>Add New Group :

<asp:TextBoxID="txt_insertname"runat="server"></asp:TextBox>

<asp:LinkButtonID="btn_insert"runat="server">Insert</asp:LinkButton>

</b>

<asp:LabelID="lbl_msg"runat="server"EnableViewState="False"ForeColor="Red"></asp:Label>

</td>

</tr>

</table>

<asp:ObjectDataSourceID="ds_groups"runat="server"DeleteMethod="Delete"InsertMethod="Insert"

SelectMethod="GetDataByWhere"TypeName="schedule.MainTableAdapters.T_GroupNameTableAdapter"

UpdateMethod="Update">

<DeleteParameters>

<asp:ParameterName="pk_groupname"Type="Int32"/>

</DeleteParameters>

<UpdateParameters>

<asp:ParameterName="pk_groupname"Type="Int32"/>

<asp:ParameterName="name"Type="String"/>

</UpdateParameters>

<InsertParameters>

<asp:ParameterName="name"Type="String"/>

<asp:ParameterDirection="InputOutput"Name="pk_groupname"Type="Object"/>

</InsertParameters>

<SelectParameters>

<asp:ParameterName="WhereCondition"Type=string/>

<asp:ParameterDefaultValue="[name]"Name="OrderByExpression"Type="String"/>

</SelectParameters>

</asp:ObjectDataSource>

<asp:SqlDataSourceID="dsrc_resourcenames"runat="server"CacheDuration="120"ConnectionString="<%$ ConnectionStrings:schedule.My.MySettings.conn_Schedule %>"

EnableCaching="True"SelectCommand="SELECT [pk_resource], [name] FROM [T_Resource] ORDER BY [name]">

</asp:SqlDataSource>

<br/>

<tablewidth="100%"cellpadding="0"cellspacing="1"bgcolor="gainsboro">

<tr>

<tdbgcolor="whitesmoke"height="25"><imgid="Img1"src="../images/plus.gif"align="absMiddle"/>

<b>Resources Part of This Group :</b>

</td>

</tr>

</table>

<asp:UpdatePanelrunat="server"ID="panel2"UpdateMode="Conditional">

<ContentTemplate>

<span>UpdatePanel 2: <%=DateTime.Now.ToString( ) %></span>

<asp:GridViewID="gv_GroupResources"runat="server"AutoGenerateColumns="False"

DataSourceID="dsrc_groupresources"SkinID=BlueSkyDataKeyNames="pk_group2resource">

<EmptyDataTemplate>

<h3>None.</h3>

</EmptyDataTemplate>

<Columns>

<asp:CommandFieldShowDeleteButton="True"DeleteText="Remove"/>

<asp:BoundFieldDataField="name"HeaderText="Name"SortExpression="name"/>

<asp:TemplateFieldHeaderText="Location"SortExpression="fk_location">

<ItemTemplate>

<%#lookup.L_Location(Eval("fk_location") - 1)("name").ToString%>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="OutputType"SortExpression="fk_outputType">

<ItemTemplate>

<imgborder=0src='../images/<%#lookup.Outputtype(Eval("fk_outputtype")-1)("icon").ToString%>'align=absbottom/>

<%#lookup.Outputtype.Item(eval("fk_outputtype")-1)("outputtype").ToString %>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="Status"SortExpression="fk_status">

<ItemTemplate>

<imgborder=0src='<%#GetResourceStatus(Eval("fk_status"), "icon")%>'align=absbottom/>

<%#GetResourceStatus(Eval("fk_status"),"name")%>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="Type"SortExpression="fk_type">

<ItemTemplate>

<imgborder=0src='<%# getResourceType(Eval("fk_type"),"icon") %>'align=absbottom/>

<%# getResourceType(Eval("fk_type"),"name") %>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

</ContentTemplate>

<Triggers>

<asp:AsyncPostBackTriggerControlID="bt"EventName="Click"/>

<asp:AsyncPostBackTriggerControlID="gv_group"EventName="SelectedIndexChanged"/>

</Triggers>

</asp:UpdatePanel>

<asp:ObjectDataSourceID="dsrc_groupresources"runat="server"DeleteMethod="Resource_DeleteFromGroupbyPK"

SelectMethod="GetData"

TypeName="schedule.MainTableAdapters.Resource_SelectGroupbyGroupPKTableAdapter">

<DeleteParameters>

<asp:ParameterName="pk_group2resource"Type="Int32"/>

</DeleteParameters>

<SelectParameters>

<asp:ControlParameterControlID="gv_group"Name="pk_group"PropertyName="SelectedValue"

Type="Int32"/>

</SelectParameters>

</asp:ObjectDataSource>

<br/>

<tablewidth="100%"cellpadding="0"cellspacing="1"bgcolor="gainsboro">

<tr>

<tdbgcolor="whitesmoke"height="25"><imgid="Img2"src="../images/plus.gif"align="absMiddle"/>

<b>Add Resource to this Group :</b></td>

</tr>

<tr>

<td>

<divid="divAdd"style="DISPLAY:inline;">

<asp:UpdatePanelrunat="server"ID="panel3"UpdateMode="Conditional"ChildrenAsTriggers="false">

<ContentTemplate>

<span>UpdatePanel 3: <%=DateTime.Now.ToString( ) %></span>

Filter Location :<asp:DropDownListID="dd_add_location"runat="server"AutoPostBack=trueAppendDataBoundItems=trueOnSelectedIndexChanged="dd_add_location_SelectedIndexChanged">

<asp:ListItemText="All"Value="0"></asp:ListItem>

</asp:DropDownList>

Filter OutputType :

<asp:DropDownListID="dd_add_outputtype"runat="server"AutoPostBack=trueAppendDataBoundItems=trueOnSelectedIndexChanged="dd_add_outputtype_SelectedIndexChanged">

<asp:ListItemText="All"Value="0"></asp:ListItem>

</asp:DropDownList>

<br/>

Resource Name :

<asp:DropDownListID="dd_add_resource"runat="server"DataSourceID="dsrc_filter_resources"DataTextField="name"DataValueField="pk_resource">

</asp:DropDownList>

<asp:LinkButtonID="btn_add_resource"runat="server"OnClick="btn_add_resource_Click">Add to Group</asp:LinkButton>

<asp:LabelID="lbl_msg2"runat="server"EnableViewState="False"ForeColor="Red"></asp:Label>

<asp:LinkButtonrunat="server"ID="bt"Text="Refresh"OnClick="bt_Click"/>

</ContentTemplate>

</asp:UpdatePanel>

</div></td>

</tr>

</table>

<asp:SqlDataSourceID="dsrc_filter_resources"runat="server"ConnectionString="<%$ ConnectionStrings:schedule.My.MySettings.conn_Schedule %>"

DataSourceMode="DataReader"SelectCommand="SELECT [pk_resource], [name] FROM [T_Resource] ORDER BY [name]">

</asp:SqlDataSource>

</form>

</body>

</html>


When you have multiple UpdatePanels having the same Trigger, all of the update panels will update, but is the processing really async or not? I am asking as I need to have one trigger ('search button') which triggers updating multiple UpdatePanels, AND I would like to detect when each of the UpdatePanels has been updated so I can indicate this outside of the individual UpdatePanels (each UpdatePanel has an associated 'tab' where an animated image displays while the request is running). The PageRequestManager (and it's endRequest) does not seem to help as it will only fire once (with an array of the names of all of the updated UpdatePanels available). I would like a way to trigger separate 'requests' (and react to the ending of each one separately). Thoughts?
hello.
nop. they're all updated udring the same postback. that's why you're getting the results you describe.

Monday, March 26, 2012

my comment on atlas (ajax) beta 1

i installed the new ctp(beta 1) and removed it and go buck to july ctp atlas

big problems that my projects fails:

1. page.clientscript.registerstartupscript - not working

insted i found some bizar fix like Microsoft.Web.Ui.Scriptmanager.RegisterStartupScript(....)

the problem with it that (allserver controls and some client click events that use 'page.clientscript.registerstartupscript' need to be updated somehow - and who has alot of server controls and alot of code it's alot of fixing and debbuging)

2. pageMethods - not working

and even the fix is no good for a system that uses pageMethods that reads data from aspx file

because the method(function) must bestatic c# /shared on vb

and becasue the need to be static

viewstate -can't exist in static function,this/Me (this.someControlName) can't exist in static function

so my suggest is (make some compatibility) to july ctp of atlas

any why i am done with this beta realese

p.s.

great job atlas team

hello.

let me add my comments:

1. it's not a bizarre fix...it's a way to ensure that everything works. it's funny that you mention that since i was under the impression that many controlos broke because the clientscriptmanager methods were used...

2. don't tell me that you were using page methods for anything...could you give me an example where you need a page method? i mean, passing everything to the server just to get a response back is not really a performant behavior...


example u ask:

there are many ways of transfering data between pages

and yes PageMethods are one of them

i transfer from child window data to parent window with pagemethods, in parent window some function

commited and creats file with all inputs from child and parent

i got pages that use this method, that's why i need pagemethod like july ctp

----------------------------------

before atlas i used the dll below

and the way i use pageMethod i used this ajaxpro dll

so -compatibility - if no the have torebuild with every new ctp or beta

http://ajaxpro.schwarz-interactive.de/

did u ever used this ajax ? (link above)

before the big "atlas" of microsoft

there was some great dll called "ajax pro" byschwarz

and i build my system ajax on is dll.


hello again.

well, if you such ajax believer (which i'm not), then you surelly know that true ajax programming is on the client. this means you use javascript and xml and perform remote web method calls to get the data. pagemethod as it was presented in previous release was nonsense: you send everything back to the server just to get a result back on the server and in all cases, you really didn't need all that info that was sent back to the server. using it means wasting network bandwith. so i'm really glad they've removed it from the bits.

regarding ajax pro, nothing prevents you from still using it...