Just another WordPress.com weblog

Archive for February, 2014

test 1

<%@ Control Language=”C#” AutoEventWireup=”true” CodeBehind=”WebUserControl1.ascx.cs” Inherits=”WebApplicationRepeater.WebUserControl1″ %>

<link rel=”stylesheet” href=”http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css&#8221; />
<link rel=”stylesheet” href=”http://jqueryui.com/resources/demos/style.css&#8221; />

<%– <link href=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css&#8221; rel=”stylesheet” type=”text/css”/>–%>

<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>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js”></script&gt;
<script src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js”></script&gt;

 <script type=”text/javascript” src=”http://maps.googleapis.com/maps/api/js?sensor=false”></script&gt;

    <script type=”text/javascript”>
    var markers = [
    <asp:Repeater ID=”rptMarkers” runat=”server”>
    <ItemTemplate>
             {
“ID”: ‘<%# Eval(“ID”) %>’,
                “title”: ‘<%# Eval(“Name”) %>’,
                “lat”: ‘<%# Eval(“lat”) %>’,
                “lng”: ‘<%# Eval(“lng”) %>’,
                “description”: ‘<%# Eval(“Description”) %>’
            }
    </ItemTemplate>
    <SeparatorTemplate>
        ,
    </SeparatorTemplate>
    </asp:Repeater>
    ];
    </script>
   
<script type=”text/javascript” language=”javascript”>
var map = null;
window.onload = function () {
//alert(markers.length);
for (i = 0; i < markers.length; i++) {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var data = markers[i];

//var map = new google.maps.Map(document.getElementById(“dvMap” + (i + 1)), mapOptions);
var map = new google.maps.Map(document.getElementById(“dvMap” + data.ID), mapOptions);
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, “click”, function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}

function initializeMap() {
//alert(markers.length);
for (i = 0; i < markers.length; i++) {
var mapOptions = {
center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var infoWindow = new google.maps.InfoWindow();
var data = markers[i];

//var map = new google.maps.Map(document.getElementById(“dvMap” + (i + 1)), mapOptions);
var map = new google.maps.Map(document.getElementById(“dvMap” + data.ID), mapOptions);
var myLatlng = new google.maps.LatLng(data.lat, data.lng);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: data.title
});
(function (marker, data) {
google.maps.event.addListener(marker, “click”, function (e) {
infoWindow.setContent(data.description);
infoWindow.open(map, marker);
});
})(marker, data);
}
}

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

// });

$(id).accordion();

$(id).bind(‘accordionchange’, function (event, ui) {
//// if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {
//alert(“hahshds”);
initializeMap();
//}
});
}

});

$(document).ready(function () {

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

// });

$(id).accordion();
$(id).bind(‘accordionchange’, function (event, ui) {
//// if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {
//alert(“hahshds”);
initializeMap();
//}
});
}
});
$(function () {

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

$(“#accordion1”).accordion();
$(“#accordion1”).bind(‘accordionchange’, function (event, ui) {
//if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {

initializeMap();
//}
});
});

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

// });
$(“#accordion1”).accordion();
$(“#accordion1”).bind(‘accordionchange’, function (event, ui) {
// if (ui.newContent.attr(‘id’) == ‘tabThree’ && !map) {

initializeMap();
//}
});
});
</script>

<div id=”accordion1″ style=”width: 900px;”>
<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: 800px;”>
<asp:Repeater runat=”server” ID=”repAccordian” onitemdatabound=”repAccordian_ItemDataBound”>
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<h3><%# Eval(“Name”) %></h3>
<%–<asp:Panel ID=”pnlTitle” runat=”server”></asp:Panel>–%>
<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>

<asp:Label ID=”lblName” Text='<%#Eval(“ID”) %>’ runat=”server”></asp:Label>
<asp:Label ID=”lbllat” Text='<%#Eval(“lat”) %>’ runat=”server”></asp:Label>
<asp:Label ID=”lbllng” Text='<%#Eval(“lng”) %>’ runat=”server”></asp:Label>
</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 border=”1″>
<tr>
<td>
<b>Description</b>
</td>
<td>
<%#Eval(“Description”) %>
</td>
<td rowspan=”3″ colspan=”2″>
<b>Google Map</b>
<asp:UpdatePanel ID=”UpdatePanel1111″ runat=”server”>
<Triggers>
<asp:PostBackTrigger ControlID=”rptMaps” />

</Triggers>
<ContentTemplate>
<asp:Repeater ID=”rptMaps” runat=”server”>
        <ItemTemplate>
            <div id=’dvMap<%#Eval(“ID”) %>’ style=”width: 400px; height: 300px”>
            </div>
        </ItemTemplate>
        <SeparatorTemplate>
            <hr />
        </SeparatorTemplate>
    </asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Panel ID=”pnlDiv” runat=”server”>dvMap<%#Eval(“ID”) %>
 

</asp:Panel> <%–<div id=”Gmap” style=”height:300px;width:400px;border:1px;border-color:Red;border-style:solid;”></div>–%>
</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.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace WebApplicationRepeater
{
public partial class WebUserControl1 : System.Web.UI.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);
}
}

rptMarkers.DataSource = createDataTableGMAP(“MARKER”);
rptMarkers.DataBind();

}

 

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;
}

public DataTable createDataTableGMAP(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);

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

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

if (id == “MARKER”)
{

dt.Rows.Add(new object[] { “110”, “Max 1 HYD”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 HYD”, “17.419640”, “78.483887” });

 

dt.Rows.Add(new object[] { “120”, “Max 1111”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789”, “17.694596”, “83.283539” });

dt.Rows.Add(new object[] { “130”, “Albert 2 CHE”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 Chennai “, “13.034864”, “80.256805” });

dt.Rows.Add(new object[] { “140”, “Destin 3 BLR”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 BANGLRE “, “12.970636”, “77.587128” });

dt.Rows.Add(new object[] { “150”, “Jessie 4 CBE”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 CBE “, “10.993301”, “76.938934” });

dt.Rows.Add(new object[] { “160”, “Joe 5 OOTY”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 OOTY”, “11.408217”, “76.702728” });

}
else
{
if (id == “110”)
dt.Rows.Add(new object[] { “110”, “Max 1 HYD”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 HYD”, “17.419640”, “78.483887” });

if (id == “120”)
dt.Rows.Add(new object[] { “120”, “Max 1111”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789”, “17.694596”, “83.283539” });
if (id == “130”)
dt.Rows.Add(new object[] { “130”, “Albert 2 CHE”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 Chennai “, “13.034864”, “80.256805” });
if (id == “140”)
dt.Rows.Add(new object[] { “140”, “Destin 3 BLR”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 BANGLRE “, “12.970636”, “77.587128” });
if (id == “150”)
dt.Rows.Add(new object[] { “150”, “Jessie 4 CBE”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 CBE “, “10.993301”, “76.938934” });
if (id == “160”)
dt.Rows.Add(new object[] { “160”, “Joe 5 OOTY”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 OOTY”, “11.408217”, “76.702728” });

}
return dt;

}

//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);

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

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

if (id == “Max”)
{
dt.Rows.Add(new object[] { “110”, “Max 1 HYD”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 HYD”, “17.419640”, “78.483887” });
dt.Rows.Add(new object[] { “120”, “Max 1111”, “Hello my name is Max and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789”, “17.694596”, “83.283539” });
}
if (id == “Albert”)
dt.Rows.Add(new object[] { “130”, “Albert 2 CHE”, “Hello my name is Albert and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 Chennai “, “13.034864”, “80.256805” });
if (id == “Destin”)
dt.Rows.Add(new object[] { “140”, “Destin 3 BLR”, “Hello my name is Destin and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 BANGLRE “, “12.970636”, “77.587128” });
if (id == “Jessie”)
dt.Rows.Add(new object[] { “150”, “Jessie 4 CBE”, “Hello my name is Jessie and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 CBE “, “10.993301”, “76.938934” });
if (id == “Joe”)
dt.Rows.Add(new object[] { “160”, “Joe 5 OOTY”, “Hello my name is Joe and I am software engineer.”, “Demo@Gmail.com”, “My Phone is 123456789 OOTY”, “11.408217”, “76.702728” });

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”);
string id = lbl.Text + item.ItemIndex.ToString();

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

 

//System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), “Script”, “alert(‘” + id + “‘);”, true);
}
}

protected void repAccordian_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{

Control pnlTitle = item.FindControl(“pnlTitle”);

Control repAccordianChild1 = item.FindControl(“pnlDiv”);
Label lbl = (Label)item.FindControl(“lblName”);
Label lbllat = (Label)item.FindControl(“lbllat”);
Label lbllng = (Label)item.FindControl(“lbllng”);

DataTable dt = new DataTable();
dt = createDataTableGMAP(lbl.Text);

rptMarkers.DataSource = dt;
rptMarkers.DataBind();

Repeater rptMaps = (Repeater)item.FindControl(“rptMaps”);

rptMaps.DataSource = dt;
rptMaps.DataBind();

 

// string id = lbl.Text;// item.ItemIndex.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();//lbl.Text +
//string divid = “<div style=’ border:1px;border-color:Red;border-style:solid;width:500px; height:300px;’ id='” + id.Replace(” “,””) + “‘>” + id.Replace(” “,””) + “</div>”;
//LiteralControl ltc = new LiteralControl(divid);
//string dividTitle = “<h3>” + lbl.Text + “</h3>”;
//LiteralControl ltcTitle = new LiteralControl(dividTitle);

//pnlTitle.Controls.Add(ltcTitle);

//repAccordianChild1.Controls.Add(ltc);

// System.Web.UI.ScriptManager.RegisterClientScriptBlock(repAccordianChild1, this.GetType(), “Script”, “ShowMap(” + id.Replace(” “, “”) + “,” + lbllat.Text.Replace(” “, “”) + “,” + lbllng.Text.Replace(” “, “”) + “);”, true);
}
}
}
}
——————————-

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();
}
}
}
}

Tag Cloud