Just another WordPress.com weblog

test

<%@ Assembly Name=”$SharePoint.Project.AssemblyFullName$” %>
<%@ Assembly Name=”Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”Utilities” Namespace=”Microsoft.SharePoint.Utilities” Assembly=”Microsoft.SharePoint, Version=14.0.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Register Tagprefix=”asp” Namespace=”System.Web.UI” Assembly=”System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35″ %>
<%@ Import Namespace=”Microsoft.SharePoint” %>
<%@ Register Tagprefix=”WebPartPages” Namespace=”Microsoft.SharePoint.WebPartPages” Assembly=”Microsoft.SharePoint,
Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
<%@ Control Language=”C#” AutoEventWireup=”true” CodeBehind=”VisualWebPart1UserControl.ascx.cs”
Inherits=”VisualWebPartProjectContactUs.VisualWebPart1.VisualWebPart1UserControl” %>
<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css”&gt;
<script src=”http://code.jquery.com/jquery-1.9.1.js&#8221; type=”text/javascript” language=”javascript”></script>
<script src=”http://code.jquery.com/ui/1.10.4/jquery-ui.js&#8221; type=”text/javascript” language=”javascript”></script>
<link rel=”stylesheet” href=”http://jqueryui.com/resources/demos/style.css&#8221; />

 

<script type=”text/javascript” language=”javascript”>
$(function () {
for (i = 1; i < 6; i++) {
//var id = “#repAccordian1_ctl0” + i + “_accordionChild1”;
var id = “#ctl00_ctl23_g_9ce9db84_b6e9_4849_b350_bdae4d70b845_ctl00_repAccordian1_ctl0” + i + “_accordionChild1”;
//alert(id);
$(id).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true
});
}

});

$(document).ready(function () {

for (i = 0; i < 6; i++) {
//var id = “#repAccordian1_ctl0” + i + “_accordionChild1”;
var id = “#ctl00_ctl23_g_9ce9db84_b6e9_4849_b350_bdae4d70b845_ctl00_repAccordian1_ctl0” + i + “_accordionChild1”;
//alert(id);
//alert(id);
$(id).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true

});
}
});
$(function () {

$(“#accordion1”).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true
});
});

$(document).ready(function () {
$(“#accordion1”).accordion({
heightStyle: “content”,
collapsible: true,
navigation: true

});
});
</script>

<div id=”accordion1″ style=”width: 800px;”>
<asp:Repeater runat=”server” ID=”repAccordian1″
onitemdatabound=”repAccordian1_ItemDataBound”>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<h3><asp:Label ID=”lblName” runat=”server” Text='<%# Eval(“Name”) %>’></asp:Label></h3>
<%– <asp:Label ID=”lblID” runat=”server” Text='<%#Eval(“ID”) %>’></asp:Label>–%>
<div id=”accordionChild1″ runat=”server” style=”width: 500px;”>
<asp:Repeater runat=”server” ID=”repAccordian”>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<h3><%#Eval(“Name”) %></h3>
<div>
<asp:UpdatePanel ID=”UpdatePanel22″ runat=”server”>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=”btnShowLabel” />
<asp:AsyncPostBackTrigger ControlID=”btnClear” />
</Triggers>
<ContentTemplate>
<asp:Panel ID=”pnl” runat=”server” Visible='<%# ServerSideMethod(Convert.ToInt32(Eval(“ID”))) %> ‘>
<table border=”1″>
<tr>
<td>
<%#Eval(“ID”) %>
</td>
<td>
FirstName:<asp:TextBox ID=”txtName” runat=”server”></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
LastName:<asp:TextBox ID=”txtLName” runat=”server”></asp:TextBox>
</td>
<tr>
<td>
</td>
<td>
Email:<asp:TextBox ID=”txtEmail” runat=”server”></asp:TextBox>
</td>
<tr>
<td>
<asp:Button ID=”btnShowLabel” runat=”server” Text=”Submit” />
</td>
<td>
<asp:Button ID=”btnClear” runat=”server” Text=”Clear” />
</td>
</tr>
<tr>
<td>
<asp:Label ID=”lbShowing” runat=”server” />
</td>
</tr>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<table>
<tr>
<td>
<b>Description</b>
</td>
<td>
<%#Eval(“Description”) %>
</td>
</tr>
<tr>
<td>
<b>Email</b>
</td>
<td>
<%#Eval(“Email”) %>
</td>
</tr>
<tr>
<td>
<b>Phone</b>
</td>
<td>
<%#Eval(“Phone”) %>
</td>
</tr>
</table>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
——————————————————————-
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;

namespace VisualWebPartProjectContactUs.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

createAccordianUsingRepeater();

}
foreach (RepeaterItem ritem in repAccordian1.Items)
{
Repeater repAccordianChild = (Repeater)ritem.FindControl(“repAccordian”);
foreach (RepeaterItem ritem1 in repAccordianChild.Items)
{
Button btn = ritem1.FindControl(“btnShowLabel”) as Button;
btn.Click += new EventHandler(btn_Click);
Button btn1 = ritem1.FindControl(“btnClear”) as Button;
btn1.Click += new EventHandler(btn1_Click);
}
}
}

 

void btn_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
RepeaterItem ritem = (RepeaterItem)btn.NamingContainer;
Label lb = (Label)ritem.FindControl(“lbShowing”);
TextBox txt = (TextBox)ritem.FindControl(“txtName”);
//getDATA(txt.Text);

((Label)ritem.FindControl(“lbShowing”)).Text = txt.Text;
((TextBox)ritem.FindControl(“txtName”)).Text = “”;

}
void btn1_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
RepeaterItem ritem = (RepeaterItem)btn.NamingContainer;

((TextBox)ritem.FindControl(“txtName”)).Text = “”;

((TextBox)ritem.FindControl(“txtEmail”)).Text = “”;
((TextBox)ritem.FindControl(“txtLName”)).Text = “”;
((TextBox)ritem.FindControl(“txtName”)).Focus();
((Label)ritem.FindControl(“lbShowing”)).Text = “”;
}

public bool ServerSideMethod(int n)
{
if (Convert.ToInt32(n) % 2 == 0)
return true;
else
return false;
}
public string GETDIVID(string n)
{
return “#accordion” + n;
}

//using System.Data;
public DataTable createDataTable(string id)
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = “ID”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Name”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Description”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Email”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Phone”;
dc.DataType = typeof(string);

dt.Columns.Add(dc);

if (id == “Max”)
{
dt.Rows.Add(new object[] { “1”, “Max 1”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789” });
dt.Rows.Add(new object[] { “1”, “Max 1111”, “Hello my name is Max and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789” });
}
if (id == “Albert”)
dt.Rows.Add(new object[] { “2”, “Albert 2”, “Hello my name is Albert and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789” });
if (id == “Destin”)
dt.Rows.Add(new object[] { “3”, “Destin 3”, “Hello my name is Destin and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789” });
if (id == “Jessie”)
dt.Rows.Add(new object[] { “4”, “Jessie 4”, “Hello my name is Jessie and I am software engineer.”,
“Demo@Gmail.com”, “My Phone is 123456789” });
if (id == “Joe”)
dt.Rows.Add(new object[] { “5”, “Joe 5”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789” });

return dt;

}

public void createAccordianUsingRepeater()
{
repAccordian1.DataSource = createDataTable1();
repAccordian1.DataBind();
}

public DataTable createDataTable1()
{
DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = “ID”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Name”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Description”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Email”;
dc.DataType = typeof(string);
dt.Columns.Add(dc);

dc = new DataColumn();
dc.ColumnName = “Phone”;
dc.DataType = typeof(string);

dt.Columns.Add(dc);

dt.Rows.Add(new object[] { “1”, “Max”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My
Phone is 123456789″ });
dt.Rows.Add(new object[] { “2”, “Albert”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789” });
dt.Rows.Add(new object[] { “3”, “Destin”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789” });
dt.Rows.Add(new object[] { “4”, “Jessie”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”,
“My Phone is 123456789” });
dt.Rows.Add(new object[] { “5”, “Joe”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My
Phone is 123456789″ });

return dt;

}

protected void repAccordian1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
Repeater repAccordianChild = (Repeater)item.FindControl(“repAccordian”);
Label lbl = (Label)item.FindControl(“lblName”);

//DataRowView drv = (DataRowView)item.DataItem;
repAccordianChild.DataSource = createDataTable(lbl.Text);
repAccordianChild.DataBind();
}
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tag Cloud

%d bloggers like this: