Reputation: 57
Hi am new to J Query and in my project I want to implement J query Accordion from C# code behind but i don't know how to add controls to jquery Accordion am using following code but this add controls to Accordion tab not to content
following code for aspx
<script type="text/javascript">
$(function () {
$("#accordion").accordion({
heightStyle: "content"
});
});
</script>
<div id="accordion" runat="server">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<h3>
<%# DataBinder.Eval(Container.DataItem, "Mobile_Name")%>
</h3>
<div>
<p>
<%# DataBinder.Eval(Container.DataItem, "Description")%>
</p>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
Following code for .cs
TextBox txtEmail = new TextBox();
txtEmail.ID = "txtEmail";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select * from Mobile", con);
DataSet ds = new DataSet();
da.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
accordion.Controls.Add(txtEmail);
please tell me solution Thanks
Upvotes: 1
Views: 1193
Reputation: 2485
If you want your txtEmail to be part of the accordion you have to use markup that is compatible with the accordion. Instead of only adding the textbox add the following:
// First add the header component
accordion.Controls.Add(new HtmlGenericControl("h3") { InnerText = "Email" });
// Then create the div for the accordion content
HtmlGenericControl div = new HtmlGenericControl("div");
// Add your textbox to the content div for the accordion
div.Controls.Add(txtEmail);
// Finally add the div to the accordion completing the accordion tab set
accordion.Controls.Add(div);
Note: Code is handwritten without compilation verification. If it doesn't compile let me know :)
Upvotes: 3