Showing posts with label containing. Show all posts
Showing posts with label containing. Show all posts

Wednesday, March 28, 2012

Control Events in Accordion

I have an accordion control which contains several panes each containing a GridView (by using ConentTemplate). I would like to give the user the ability to edit GridView items inline. The problem is that I must click twice to put the item into edit mode. I have seen other posts with similar problems but no definite solution. Any help would be greatly appreciated.

1 <ajaxToolkit:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader"2 ContentCssClass="accordionContent" SelectedIndex="0"3 AutoSize="None" FadeTransitions="false" FramesPerSecond="40" TransitionDuration="250" EnableViewState="true" >4567 <HeaderTemplate><a class="accordionLink" id="accordionLink" href="http://links.10026.com/?link=" onclick="return false;"><%# ((Person)((DictionaryEntry)Container.DataItem).Key).FirstName + " " + ((Person)((DictionaryEntry)Container.DataItem).Key).LastName%></a></HeaderTemplate>89 <ContentTemplate>10111213 <asp:GridView EnableViewState="true" ID="GridViewOpen" OnRowUpdating="GridViewOpen_RowUpdating" OnInit="GridViewOpen_Init" OnRowEditing="GridViewOpen_RowEditing" OnRowCancelingEdit="GridViewOpen_RowCancelingEdit" OnSelectedIndexChanged="GridViewOpen_SelectedIndexChanged" runat="server" DataSource="<%# ((DictionaryEntry)Container.DataItem).Value%> "14 AutoGenerateColumns="false" AutoGenerateEditButton="true" AutoGenerateSelectButton="false" AllowSorting="true">15 <Columns>16171819 <asp:TemplateField HeaderText="MoNumber" SortExpression="MoNumber">20 <EditItemTemplate>21 <asp:TextBox ID="LabelEditMoNumber" runat="server" Text='<%# Bind("MoNumber")%>'></asp:TextBox>22 </EditItemTemplate>23 <ItemTemplate>24 <asp:Label ID="LabelViewMoNumber" runat="server" Text='<%# Bind("MoNumber")%>'></asp:Label>2526 </ItemTemplate>27 </asp:TemplateField>2829303132 <asp:TemplateField HeaderText="Location" SortExpression="LocationId">33 <EditItemTemplate>34 <asp:DropDownList runat="server" id="dataLocationId" DataSourceID="objDsLocationId" DataTextField="Name" DataValueField="LocationId" SelectedValue='<%# Bind("LocationId")%>'></asp:DropDownList>35 </EditItemTemplate>36 <ItemTemplate>37 <asp:Label ID="Label2" runat="server" Text='<%# FindLocation(Eval("LocationId"))%>'></asp:Label>38 </ItemTemplate>39 </asp:TemplateField>40 <asp:TemplateField HeaderText="Time (Hrs)">41 <ItemTemplate>42 <asp:Label ID="Label3" runat="server" Text='-'></asp:Label>43 </ItemTemplate>44 </asp:TemplateField>4546474849 </Columns>50 </asp:GridView>5152 </ContentTemplate>5354 </ajaxToolkit:Accordion>


I too have this problem with a normal LinkButton
Same problem here too, and it's driving me bonkers :(
I see you are not using panes inside the accordion. Is this because you only need one pane? I thought you'd need one pane for every GridViewConfused
In my project, I am using Panes and I'm still having issued. All the Panes are being loaded dynamically though, which I need to do that way. Any ideas out there?

All I have the solution, it dosen't make sence but it solves the problem

at the page Load create a pointer to the control for example

Dim btnAs Button =CType(Accordion1.Panes(0).FindControl("btnQuickSearch"), Button)

Where btnQuickSearch is the id of the button

Good Luck


This seems like a common problem.

The example above works for an accordion with only one pane. However, if I do the same to try and initialize controls in the second, or third pane it doesn't work. I can reference the controls in my code, however I still have to click a button twice to fire the event.

Does anyone have any thoughts on how to avoid this? Or, can I catch the accordion transition event (if there is one) and then initialize my controls for that pane in that event?

This one has me stumped.


I'm having almost the exact same issue. I am creating what is essentially a datagrid-accordion where each line of the control is an accordion panel. I managed to get sorting and paging to work, but they are outside the actual accordion control. I can't make the controls inside the accordion pane to trigger their appropriate event. At one point I was able to have them fire on the second click, but after adding a command name and command argument to the buttons, they don't do that anymore.

I would also like to be able to have a 'cancel' button that closes the panel, but nothing is working. The cancel button could be done with javascript, but no one seems to know how to do this. Are there no solutions to these problems? I don't want to have to make with a complicated work around where I have to create the buttons inside the accordions data bind event... its way more hassle than its worth.

Thanks


Yup I'm where you're at as well. It's a little silly that just getting buttons to work in an accordion can be so complex haha.

I have gotten buttons to work, but only when I manually create the accordionpanes and do the oninit() trick. That's not we want of course, there must be a way to wire up a databound accordion to get control events to fire. I don't know how to tap into an accordionpane's oninit function when they are created through databinding though, does anyone have a solution?

- Calvin


So far the best I can do is get the double click effect on a databound accordion. Add a empty panel and set its visibility to false, and you get the problems noted herehttp://forums.asp.net/t/1017782.aspx. But the fixes they talked about don't seem to work for the databound panels.

If I get any farther with a work around I will let you all know.


Ok, so what I came up with was to actually change the source code. Its not a lot to change, but its not 100% perfect.

Also, I can't take credit for this, because I gathered the combined changes required from various sources, but here it is:

TheAccordion Class needs to be changed from aWebControl to aCompositeControl.

source:here

And both theAccordion Class and theAccordion Panel Class need to use theINamingContainer.

source:here

Here is an example of the change:

was:public class Accordion : WebControl

is now:public class Accordion : CompositeControl, INamingContainer

Hope this helps some people.


I made the change but now clicking buttons makes the entire accordion disappear. I'm not positive it's due to changing the base to compositecontrol though, because I was fiddling with a ton of other stuff before I caught your post. It's way too late in my project to try to keep messing around with the control however, so it's back to old school repeaters for me.


CalZ:

I made the change but now clicking buttons makes the entire accordion disappear. I'm not positive it's due to changing the base to compositecontrol though, because I was fiddling with a ton of other stuff before I caught your post. It's way too late in my project to try to keep messing around with the control however, so it's back to old school repeaters for me.

I had that issue as well... where are you doing the databind?


I'm binding it in the markup:

<cc1:Accordion ID="AccordionResults" runat="server" DataSourceID="SqlDataSourceResults" SelectedIndex="-1" RequireOpenedPane="false" FadeTransitions="true" OnItemCreated="InitPanes" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordionContent" Width="800px">

And onItemCreated calls:

Protected Sub InitPanes(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionItemEventArgs)

Dim myAccordionPane As AjaxControlToolkit.AccordionContentPanel = CType(e.AccordionItem, AjaxControlToolkit.AccordionContentPanel)
Dim workAroundLabel As New Label
workAroundLabel.Visible = False
myAccordionPane.Controls.Add(workAroundLabel)

End Sub


Well, before I make any suggestions, realize I am not an expert at this by any measure. But when I experienced the same symptoms, it was because I was Adding controls before I was binding the data (so adding controls to an accordion with no panes), or at least thats what I thought.

Looking at you're code, my only suggestion is that you remove the work around label and give it one last try.

Sorry I cant be of more help.

Content Place Holder containing accordion control

Hi

I'm new'ish to ASP (AJAX) and was trying to create a web site. Most has gone fine but I have a Master page with a content Place Holder on it.

I tried to put an accordion control on (between content tags) and it told me I needed a Script Manager which I did put on. Even with no other controls / code I get errors about 'sys' is undefined from IE with line numbers etc.

It seems to be from the following lines in source

//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ctl00$ContentPlaceHolder1$ScriptManager1', document.getElementById('aspnetForm'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);
//]]>

Has anyone managed to get Accordion working with Content Place Holder and if so what am I doing wrong. I can get it workig with just a default.aspx type page.

thanks

Trev

The sample website uses a master page. So the accordiondemo shows the usage of the control inside a content placeholder. Check it out the accordion.aspx demo page code for more details. You can download the code for the toolkit which includes the sample website from thecodeplex site.

Thanks

I rebuilt the default.aspx file and it seemed to cure the problem. Now I just have the problem of Contant place holder not sizing correctly

thanks again

Content Page Problem

Hi;

I have a masterpage with a script manager and a collapse panel.

It works fine but the Content page I created containing an update panel for a grid just ignores the atlas updatepanel.

If I remove the association with the master page and add a script manger the updatepanel works fine.

I can't seem to find the problem, can anyone give me some guidance on this problem?

Thanks

Without much to go on, I'd guess that you might need to use aScriptManagerProxy.


I tried a script manager proxy it didn't help, but I was unsure of what needed to be set also I am only using the basic implementation of the updatepanel and not using any additional scripts. It seems that the master isn't communicating properly with the content page.

Here is the part of the master with the scriptmanager:

<%@.MasterLanguage="VB"CodeFile="HypnosMasterPage.master.vb"Inherits="HypnosMasterPage" %>

<%@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="cc1" %>

<!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>

<atlas:ScriptManagerID="ScriptManager1"runat="server"></atlas:ScriptManager>

</head>

<body>

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

Here is the pertinent part of contentpage: Also it is in a subfolder one level below the location of the master page

<%@.PageLanguage="VB"MasterPageFile="~/HypnosMasterPage.master"AutoEventWireup="false"CodeFile="UserLookup.aspx.cs"Inherits="UserLookup"Title="UserLookup" %>

<%@.RegisterAssembly="AtlasControlToolkit"Namespace="AtlasControlToolkit"TagPrefix="atlasToolkit" %>

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server">

<atlas:UpdatePanelID="UpdatePanel1"runat="server"Mode="Conditional">

<ContentTemplate>

<asp:GridViewrunat="server"ID="grid"></asp:GridView>

</ContentTemplate>

<Triggers>

<atlas:ControlEventTriggerControlID="btnGo"EventName="Click"/>

<atlas:ControlEventTriggerControlID="txtPatientSearch"EventName="TextChanged"/>

</Triggers>

</atlas:UpdatePanel>

Any thoughts?

Len


When I looked at the html again I found my own problem missing enable attribute, sorry to take up your time thanks for the tips.

Len