Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

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

Sponsored Links

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
 
LinkBack Thread Tools Display Modes
  #1  
Old June 24th, 2008, 10:47 AM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 417
Thanks: 26
Thanked 34 Times in 34 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
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  
Old June 24th, 2008, 12:15 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net 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
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old June 24th, 2008, 05:13 PM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 417
Thanks: 26
Thanked 34 Times in 34 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
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  
Old June 24th, 2008, 05:18 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 863
Thanks: 20
Thanked 78 Times in 75 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead is a jewel in the roughjmurrayhead is a jewel in the roughjmurrayhead is a jewel in the rough

Awards Showcase
Microsoft Windows Microsoft SQL Server Microsoft .Net 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  
Old June 24th, 2008, 05:28 PM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 417
Thanks: 26
Thanked 34 Times in 34 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
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  
Old June 24th, 2008, 05:36 PM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 417
Thanks: 26
Thanked 34 Times in 34 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
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  
Old June 25th, 2008, 04:37 AM
richyrich's Avatar
Super Moderator
 
Join Date: Mar 2008
Location: Somewhere only we know...
Posts: 417
Thanks: 26
Thanked 34 Times in 34 Posts
Blog Entries: 1
Rep Power: 1
richyrich will become famous soon enough

Awards Showcase
JavaScript Classic ASP 
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
Custom Calendar Control AOG123 Microsoft Access 3 September 6th, 2008 07:36 AM
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


All times are GMT -4. The time now is 08:02 PM.



Content Relevant URLs by vBSEO 3.2.0