DeveloperBarn Forums

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

Discuss "Control inside Accordion Content Template" in the .Net Development forum.

.Net Development - Learn about the Microsoft.Net framework and how to create powerful web-based (ASP.net) and client-based (Windows Forms) applications utilizing various languages such as C#, VB.Net, J# and others.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old June 24th, 2008, 10:47 AM
richyrich's Avatar
Moderator

 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 320
Thanks: 22
Thanked 23 Times in 23 Posts
Rep Power: 1
richyrich is on a distinguished road

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default Control inside Accordion Content Template

I am using the accordion ajax control to display data and have bound the accordion to a datasource. Inside the contenttemplate of the accordion I have a few checkboxes. When I try and access these controls on postback I get nothing back from them.
Code:
<ajaxtoolkit:Accordion ID="accord_phase" runat="server" FadeTransitions="false" RequireOpenedPane="false" OnItemDataBound="accord_phase_onitemdatabound" HeaderCssClass="accordionHeader" ContentCssClass="accordionContent">
 
<HeaderTemplate>
<table width="99%" cellpadding="0" cellspacing="0" border="0" class="accordiontblHeader">
<tr><td class="white9b" style="padding:1px 0px 1px 3px;cursor:pointer"><asp:Literal ID="ltl_accord_header" runat="server" Text="Section 1" /></td></tr>
</table>
</HeaderTemplate>
 
<ContentTemplate>
<asp:HiddenField ID="hdn_phaseref" runat="server" />
<table width="99%" cellpadding="0" cellspacing="0" border="0">
<tr id="tr_interest" runat="server">
<td class="frm_req"></td>
<td class="lbl_form">
<asp:Label ID="lbl_interest" Text="Registered Interest" AssociatedControlID="chk_interest" runat="server" CssClass="dblue9b" />
</td>
<td class="txt_form" nowrap="nowrap">
<asp:checkbox ID="chk_interest" runat="server" Checked="true" Enabled="false" />
</td></tr>
<tr id="tr_contact" runat="server">
<td class="frm_req"></td>
<td class="lbl_form">
<asp:Label ID="lbl_contact" Text="Contact Details" AssociatedControlID="chk_contact" runat="server" CssClass="dblue9b" />
</td>
<td class="txt_form" nowrap="nowrap">
<asp:checkbox ID="chk_contact" runat="server" />
</td></tr>
<tr id="tr_initial" runat="server">
<td class="frm_req"></td>
<td class="lbl_form">
<asp:Label ID="lbl_initial" Text="Date & Time for Initial Contact" AssociatedControlID="chk_contact" runat="server" CssClass="dblue9b" />
</td>
<td class="txt_form" nowrap="nowrap">
<asp:checkbox ID="chk_initial" runat="server" />
</td></tr>
</table>
</ContentTemplate>
 
</ajaxtoolkit:Accordion>
When I postback the page I'm using this code to try and retrieve the value in the hdn_phaseref field.
Code:
        For Each item As AjaxControlToolkit.AccordionPane In accord_phase.Panes
            Dim hdn_phaseref As HiddenField = item.ContentContainer.FindControl("hdn_phaseref")
But if I then try and write the value of the hidden field to the screen (hdn_phaseref.value) it just comes up blank.

I've tried googling but can't find any examples using it like this. The page loads exactly as it should and I don't get any errors when loading or on postback.

Is there some way I can access these controls?

Last edited by richyrich; June 24th, 2008 at 10:51 AM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old June 24th, 2008, 12:15 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 530
Thanks: 14
Thanked 38 Times in 37 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead is on a distinguished road

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

How are you setting the value of hdn_phaseref? Is the postback having an effect on its value? I haven't yet needed this control, so have no experience with it.
__________________
jmurrayhead
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net
Reply With Quote
  #3 (permalink)  
Old June 24th, 2008, 05:13 PM
richyrich's Avatar
Moderator

 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 320
Thanks: 22
Thanked 23 Times in 23 Posts
Rep Power: 1
richyrich is on a distinguished road

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

I've tried setting it as <%#Eval("phaseref")%> and hdn_phaseref.value =

When I look at the source of the page, the value shows in the hidden field.

I also have a literal control in the header template of the Accordion control and I am able to retrieve the text contained in the literal using
item.FindControl("ltl_accord_phase")

If I change FindControl("hdn_phaseref") to FindControl("jfhfv") I get an object not set to instance error, so it's obviously finding the control, but for some reason it's empty.

I think it must be somehow linked to the HeaderTemplate, but I'm not sure how yet.
Reply With Quote
  #4 (permalink)  
Old June 24th, 2008, 05:18 PM
jmurrayhead's Avatar
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 530
Thanks: 14
Thanked 38 Times in 37 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead is on a distinguished road

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

Try gaining access to the control as explained in this link: AJAX Control Library Accordion Problems - Brian Mains Blog
Reply With Quote
  #5 (permalink)  
Old June 24th, 2008, 05:28 PM
richyrich's Avatar
Moderator

 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 320
Thanks: 22
Thanked 23 Times in 23 Posts
Rep Power: 1
richyrich is on a distinguished road

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

I'm not quite sure how that would work because I'm binding the accordion to a datasource, so I can't call the control using the accordionID.FindControl as there are several instances of the same control and I don't explicitly define the accordion panes, so I can't call ths control using the ID of the pane either.

This seems very strange.
Reply With Quote
  #6 (permalink)  
Old June 24th, 2008, 05:36 PM
richyrich's Avatar
Moderator

 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 320
Thanks: 22
Thanked 23 Times in 23 Posts
Rep Power: 1
richyrich is on a distinguished road

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

OK. I seem to have got somewhere, but no idea if it's anywhere useful!!

I only seem to be able to get a value(text) from a literal control.

All other types of control come back blank....Hmmmm....

Anyone heard of this before?
Reply With Quote
  #7 (permalink)  
Old June 25th, 2008, 04:37 AM
richyrich's Avatar
Moderator

 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 320
Thanks: 22
Thanked 23 Times in 23 Posts
Rep Power: 1
richyrich is on a distinguished road

Awards Showcase
Classic ASP JavaScript 
Total Awards: 2

Default

I have found a solution of sorts....Not ideal, but it may have to do for the time being.

I have had to add an update button to the ContentTemplate of the accordion so each pane has it's own update button.

Then I added a CommandName and Argument to the update button:-
Code:
<asp:ImageButton id="img_update" runat="server" ImageURL="link_update.gif" CommandName="Update" CommandArgument='<%#Eval("phaseref")%>' />
Then to the accordion I added the OnItemCommand property to tell it how to action the command:-
Code:
<ajaxtoolkit:accordion id="accord_phase" runat="server" ....... OnItemCommand="update_phase">
And in my update_phase routine:-
Code:
Sub update_phase(ByVal s As Object, ByVal e As CommandEventArgs)
 
If e.CommandName = "Update" then
     Dim accord As AjaxControlToolkit.Accordion = s
     Dim accord_pane As AjaxControlToolkit.AccordionPane = accord.Panes(accord.SelectedIndex)
     Dim phaseref As Integer = e.CommandArgument
     Dim chk_initial As Checkbox = accord_pane.FindControl("chk_initial")
 
End If
Hope that helps someone...
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Tags
accordion, ajax, control, postback

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Webchart Control not displaying in Firefox richyrich .Net Development 1 June 2nd, 2008 01:43 PM
WebCharts Control richyrich .Net Development 1 April 4th, 2008 11:14 AM
Dynamic Content in AJAX Extender richyrich .Net Development 3 March 17th, 2008 12:14 PM
Custom Calendar Control AOG123 Microsoft Access 1 March 16th, 2008 02:06 PM


Sponsored Links

ASP.NET Resource Index
a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer.

Free Web Directory
Including Chats and Forums Resources, Offer automatic, instant and free directory submissions.
URLZ Web Directory
URLZ Web Directory

Free Web Directory - Add Your Link
The Little Web Directory
Free Web Directory
Pegasus free web directory is a free directory organised by categories.

Web Directory & SEO Services
dirroot web directory


All times are GMT -4. The time now is 07:42 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 DeveloperBarn.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46