Internet Explorer (IE) starts giving Javascript error when I tried to open Pop-up Dialog, Which works perfect with Fire Fox and Chrome.
You will find discussion topics for ASP.net, C#, JQuery, AJAX, SQL, VB.net, .Net Framework, WCF, WPF, WWF, WSS 3.0, MOSS 2007, OOPs Concepts, SQL Server, Programming.
Internet Explorer (IE) starts giving Javascript error when I tried to open Pop-up Dialog, Which works perfect with Fire Fox and Chrome.
Update to my previous post Rating Control Ajax - Display Message on Rating
Ajax Rating Control has bug, that is whenever user clicks the rating control, page causes jumps to top of the page. To avoid jump to top of page when user clicks Rating Control you need to add following line.
Add following line to maintain scroll position of page after user clicks rating control asp.net ajax.
protected void Page_Load(object sender, EventArgs e)
{
Rating1.Attributes.Add("onclick", "return false;");
}
For Detailed explanation about why Rating control jumps to top of page when user clicks on Rating control
Good Link for XSLT Transformation
XSL Transformation
Reflection is way through which we can identify metadata about assembly runtime.
Example: We have a .Net Assembly file (.dll file), which consist of 2 Class Definition and 10 Method Names, We can get information about classes and method name list through reflection.
Few Examples of Reflection
Loading Assembly FileAssembly assem = Assembly.LoadFrom(sAssemblyFileName);
Get List of Class Name.
Type[] types = assem.GetTypes();
Get List of Method Name
foreach (Type cls in types)
{
try
{
//Add Namespace Name
arrl.Add(cls.FullName);
//Add Class Name
if(cls.IsAbstract)
arrl.Add("Abstract Class:" + cls.Name.ToString());
else if(cls.IsPublic)
arrl.Add("Public Class:" + cls.Name.ToString());
else if(cls.IsSealed)
arrl.Add("Sealed Class:" + cls.Name.ToString());
MemberInfo[] methodName = cls.GetMethods();
foreach (MemberInfo method in methodName)
{
if (method.ReflectedType.IsPublic)
arrl.Add("\tPublic - " + method.Name.ToString());
else
arrl.Add("\tNon-Public - " + method.Name.ToString());
}
}
catch (System.NullReferenceException)
{
Console.WriteLine("Error msg");
}
}
private void btnListMethodName_Click(object sender, EventArgs e)
{
string sAssemblyFileName = txtAssemblyFileName.Text;
if (sAssemblyFileName.Length != 0)
{
Assembly assem = Assembly.LoadFrom(sAssemblyFileName);
Type[] types = assem.GetTypes();
ArrayList arrl = new ArrayList();
foreach (Type cls in types)
{
try
{
//Add Class Name
arrl.Add(cls.FullName);
if(cls.IsAbstract)
arrl.Add("Abstract Class:" + cls.Name.ToString());
else if(cls.IsPublic)
arrl.Add("Public Class:" + cls.Name.ToString());
else if(cls.IsSealed)
arrl.Add("Sealed Class:" + cls.Name.ToString());
MemberInfo[] methodName = cls.GetMethods();
foreach (MemberInfo method in methodName)
{
//arrl.Add("\t" + method.Name.ToString());
if (method.ReflectedType.IsPublic)
arrl.Add("\tPublic - " + method.Name.ToString());
else
arrl.Add("\tNon-Public - " + method.Name.ToString());
}
}
catch (System.NullReferenceException)
{
Console.WriteLine("Error msg");
}
}
//Dump Data to NotePad File
FileStream fs = new FileStream(@"c:\myData.txt", FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs);
for (int i = 0; i < arrl.Count; i++)
{
lstInfo.Items.Add(arrl[i].ToString());
sw.WriteLine(arrl[i].ToString());
}
sw.Flush();
sw.Close();
}
}
One Famous Problem with Rating Control is How to Display Message after Rating is done, without making use of button click.
Following Images Explain How can we display label text on Rating Control Click, without explicitly clicking any button control.
Before Rating Control is Clicked
During Rating Control is Clicked
After Rating Control is Clicked
Now, lets understand how to display message on click of Star Image.
Step1: Declare CSS Styles in Style Sheet file Also Add Images to Image Folder
.ratingStar {
font-size: 0pt;
width: 31px;
height: 30px;
margin: 0px;
padding: 0px;
cursor: pointer;
display: block;
background-repeat: no-repeat;
}
.filledRatingStar {
background-image: url(Images/FilledStar.png);
}
.emptyRatingStar {
background-image: url(Images/EmptyStar.png);
}
.savedRatingStar {
background-image: url(Images/SavedStar.png);
}
Step2: Declare ScriptManager in .aspx file with EnablePartialRendering=true
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
Step3: Declare UpdatePannel
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!-- Declare Rating Control Here -->
</ContentTemplate>
</asp:UpdatePanel>
Step4: Add Rating Control and Label in UpdatePannel
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<!-- Rating Control -->
<cc1:Rating ID="Rating1" runat="server"
BehaviorID="RatingBhvrId1"
CurrentRating="3"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="Rating1_Changed"
ToolTip="Please Rate!"
style="float:left;">
</cc1:Rating>
<!-- Label to Display Message -->
<span id="lblResponse" class="heading"></span>
</ContentTemplate>
</asp:UpdatePanel>
Step5: Declare Necessary Javascript to show "Message" after user performs Rating with the help of e.CallbackResult
Step6: Declaring Rating1_Changed Event
<script language="javascript" type="text/javascript">
Sys.Application.add_load(function()
{
$find("RatingBhvrId1").add_EndClientCallback(function(sender, e)
{
var lblCtrl = document.getElementById('lblResponse');
lblCtrl.innerHTML = e.get_CallbackResult();
});
});
</script>protected void Rating1_Changed(object sender, AjaxControlToolkit.RatingEventArgs e)
{
System.Threading.Thread.Sleep(500);
int iRate = Convert.ToInt16(e.Value);
string strMessage = string.Empty;
switch (iRate)
{
case 1:
strMessage = "Not Useful";
break;
case 2:
strMessage = "Average";
break;
case 3:
strMessage = "Useful";
break;
case 4:
strMessage = "Informative";
break;
case 5:
strMessage = "Excellent";
break;
}
strMessage = "Thanks for Rating, You found this Question " + strMessage;
e.CallbackResult = strMessage;
}
Summary View of .aspx Page
<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:Rating ID="Rating1" runat="server"
BehaviorID="RatingBhvrId1"
CurrentRating="3"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="Rating1_Changed"
ToolTip="Please Rate!"
style="float:left;">
</cc1:Rating>
<br />
<span id="lblResponse" class="heading"></span>
<script language="javascript" type="text/javascript">
Sys.Application.add_load(function()
{
$find("RatingBhvrId1").add_EndClientCallback(function(sender, e)
{
var lblCtrl = document.getElementById('lblResponse');
lblCtrl.innerHTML = e.get_CallbackResult();
});
});
</script>
</ContentTemplate>
</asp:UpdatePanel>
Finding All Controls on Page in Asp.net
To find all controls on Page, including child controls. i.e. Loop through all control list.
Example: I have a page with Controls on Page, Pannel Controls (Which contains Few more child controls). Now I want to find list of all controls on Page including child control.
private void ListControlCollections()
{
ArrayList controlList = new ArrayList();
AddControls(Page.Controls,controlList);
foreach (string str in controlList)
{
Response.Write(str + "<br/>");
}
Response.Write("Total Controls:" + controlList.Count);
}
private void AddControls(ControlCollection page,ArrayList controlList)
{
foreach (Control c in page)
{
if (c.ID != null)
{
controlList.Add(c.ID);
}
if(c.HasControls())
{
AddControls(c.Controls, controlList);
}
}
}
Tutorial Link for understanding Rhino Mocks
What is Rhino Mocks
Rhino.Mocks is an attempt to create easier way to build and use mock objects and allow better refactoring support from the current tools. It's a hybrid approach between the pure Record/Replay of EasyMock.Net's model and NMock's expectation based model. Rhino.Mocks originated from EasyMock.Net and attempt to improve on their model to create easy to use and power mocking framework. It's free for use and modification for open source and commercial software.
Rhino.Mocks is an attempt to create easier way to build and use mock objects and allow better refactoring support from the current tools. It's a hybrid approach between the pure Record/Replay of EasyMock.Net's model and NMock's expectation based model. Rhino.Mocks originated from EasyMock.Net and attempt to improve on their model to create easy to use and power mocking framework. It's free for use and modification for open source and commercial software.Rhino.Mocks is an attempt to create easier way to build and use mock objects and allow better refactoring support from the current tools. It's a hybrid approach between the pure Record/Replay of EasyMock.Net's model and NMock's expectation based model. Rhino.Mocks originated from EasyMock.Net and attempt to improve on their model to create easy to use and power mocking framework. It's free for use and modification for open source and commercial software.
Rhino.Mocks is an attempt to create easier way to build and use mock objects and allow better refactoring support from the current tools. It's a hybrid approach between the pure Record/Replay of EasyMock.Net's model and NMock's expectation based model. Rhino.Mocks originated from EasyMock.Net and attempt to improve on their model to create easy to use and power mocking framework. It's free for use and modification for open source and commercial software.
Rhino Mocks Tutorial
Useful Links for Rhino Mocks
Download Visual Studio 2010 Beta Version
VS.Net 2010 Features Good Links and Highlights
Application Architecture Guide Book for Microsoft .Net Patterns and Practise V2.0 is Released (Beta 1)
Download Book Application Architechture Guide V2.0
Index of Application Architecture Guide Book
Parts
Part I, Fundamentals of Application Architecture
Part II, Design
Part III, Layers
Part IV, Quality Attributes
Part V, Archetypes - Design and Patterns
Chapters
Introduction
Architecture Best Practices At a Glance
Fast Track - A Guide for Getting Started and Applying the Guidance
Part I, Fundamentals of Application Architecture
Chapter 1 - Fundamentals of Application Architecture
Chapter 2 - .NET Platform Overview
Chapter 3 - Application Archetypes
Chapter 4 - Deployment Patterns
Chapter 5 - Architectural Styles
Chapter 6 - Quality Attributes
Chapter 7 - Layers and Tiers
Part II, Design
Chapter 8 - Designing Your Architecture
Chapter 9 - Architecture and Design Guidelines
Chapter 10 - Designing Services
Chapter 11 - Communication Guidelines
Part III, Layers
Chapter 12 - Presentation Layer Guidelines
Chapter 13 - Business Layer Guidelines
Chapter 14 - Data Access Layer Guidelines
Chapter 15 - Service Layer Guidelines
Part IV, Quality Attributes
Chapter 16 - Performance Engineering
Chapter 17 - Security Engineering
Part V, Archetypes - Design and Patterns
Chapter 18 - Mobile Application
Chapter 19 - Office Business Application (OBA)
Chapter 20 - Rich Client Application
Chapter 21 - Rich Internet Application (RIA)
Chapter 22 - Service Archetype
Chapter 23 - SharePoint LOB Application
Chapter 24 - Web Application
Appendix
Cheat Sheet - patterns & practices Catalog at a Glance
Cheat Sheet - patterns & practices Pattern Catalog
Cheat Sheet - patterns & practices Enterprise Library
Checklist for making Browser Independent Web Application
http://developer.mozilla.org/En/Migrate_apps_from_Internet_Explorer_to_Mozilla
Mozilla Developer community is recommending following tips to make browser independent web application
General cross-browser coding tips
Differences between Mozilla and Internet Explorer
DOM differences
JavaScript differences
Differences in JavaScript-generating HTML
CSS differences
CSS overflow differences
Quirks versus standards mode
Event differences
XML differences
XSLT differences
C++ to C# Converter Utility
For migration project from C++ to C# Converter, a online utility might be helpful for getting startup stuff ready.
Check out C++ to C# Converter
Finding Distance based on Zipcode or City Name for USA
A really good article sharing how to find distance between two zip codes or cities of USA.
For whom this article is useful
DECLARE c1 CURSOR READ_ONLY
FOR
select ZipCode,Latitude,Longitude,City,State,County,ZipClass from Zip_Codes
declare @ZipCodeOriginal varchar(50)
declare @ZipCode varchar(50)
declare @Latitude varchar(50)
declare @Longitude varchar(50)
declare @City varchar(50)
declare @State varchar(50)
declare @County varchar(50)
declare @ZipClass varchar(50)
open c1
FETCH NEXT FROM c1
Into @ZipCode,@Latitude,@Longitude,@City,@State,@County,@ZipClass
WHILE @@FETCH_STATUS = 0
BEGIN
set @ZipCodeOriginal = @ZipCode
set @ZipCode = substring(@ZipCode,2,len(@ZipCode) - 2)
set @Latitude = substring(@Latitude,2,len(@Latitude) - 2)
set @Longitude = substring(@Longitude,2,len(@Longitude) - 2)
set @City = substring(@City,2,len(@City) - 2)
set @State = substring(@State,2,len(@State) - 2)
set @County = substring(@County,2,len(@County) - 2)
set @ZipClass = substring(@ZipClass,2,len(@ZipClass) - 2)
--Update
update Zip_Codes
set ZipCode=@ZipCode,
Latitude = @Latitude,
Longitude = @Longitude,
City = @City,
State = @State,
County = @County,
ZipClass = @ZipClass
where
--Uniqueness Checking
ZipCode = @ZipCodeOriginal
FETCH NEXT FROM c1
Into @ZipCode,@Latitude,@Longitude,@City,@State,@County,@ZipClass
END
CLOSE c1
DEALLOCATE c1
Set of Utility Function for SQL Server 2005
AT(): Returns the beginning numeric position of the nth occurrence of a character expression within another character expression, counting from the leftmost character.
RAT(): Returns the numeric position of the last (rightmost) occurrence of a character string within another character string.
OCCURS(): Returns the number of times a character expression occurs within another character expression (including overlaps).
OCCURS2(): Returns the number of times a character expression occurs within another character expression (excluding overlaps).
PADL(): Returns a string from an expression, padded with spaces or characters to a specified length on the left side.
PADR(): Returns a string from an expression, padded with spaces or characters to a specified length on the right side.
PADC(): Returns a string from an expression, padded with spaces or characters to a specified length on the both sides.
CHRTRAN(): Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.
STRTRAN(): Searches a character expression for occurrences of a second character expression, and then replaces each occurrence with a third character expression. Unlike a built-in function Replace, STRTRAN has three additional parameters.
STRFILTER(): Removes all characters from a string except those specified.
GETWORDCOUNT(): Counts the words in a string.
GETWORDNUM(): Returns a specified word from a string.
GETNUMWORD(): Returns the index position of a word in a string.
GETALLWORDS(): Inserts the words from a string into the table.
PROPER(): Returns from a character expression a string capitalized as appropriate for proper names.
RCHARINDEX(): Similar to the Transact-SQL function Charindex, with a Right search.
ARABTOROMAN(): Returns the character Roman numeral equivalent of a specified numeric expression (from 1 to 3999).
ROMANTOARAB(): Returns the number equivalent of a specified character Roman numeral expression (from I to MMMCMXCIX).
You can get code from this web link for each of this functions http://it.toolbox.com/wiki/index.php/User-Defined_string_Functions_MS_SQL_Server_2005_Transact-SQL_SQLCLR
Avoid Inserting Duplicate Record on Page Refresh
Problem: User Input Form Inserts Duplicate Record on Page Refresh.
Solution:
Error: Member names cannot be the save as their enclosing type
Possible Cause: Unkowingly I declare Method name, same as class name, which pops-up this error. Logically its out of blue to think, declaring method name as class name as it is constructor, but may be because of nature of application i have declare Class Name as Method Name and runs into Error: "Member names cannot be the save as their enclosing type".
Cause of Error:
public class MyClass
{
//Declaring Method Same as Class Name
//Note: its not constructor, constructor don't have return type.
public void MyClass()
{
}
}
Solution to Error:
public class MyClass
{
//Change Method Name to Something else
public void MyMethod()
{
}
}
Free E-Books for LINQ, Ajax, Silverlight
Free E-Books for New Features of .Net Framework 3.5
Sign up for the free e-book offer
The free e-book from Microsoft Press:
This book explains ASP.NET AJAX Extensions 1.0, including an overview and the control toolkit.
This book explains how to use Silverlight to simplify the way you implement compelling user experiences for the Web. Discover how to support an object-oriented program model with JavaScript.
Introduction | 1:04 | 1 MB |
Overview of WPF | 3:45 | 3.8 MB |
Overview of the Expression Suite | 2:29 | 2.9 MB |
Downloading and installing Blend | 3:29 | 6.5 MB |
Overview of the Blend interface | 6:43 | 8.2 MB |
The Tools panel | 7:16 | 9.8 MB |
The Interaction panel | 3:54 | 5 MB |
The Project panel | 2:55 | 2.9 MB |
The Properties panel | 4:15 | 4.5 MB |
The Resources panel | 2:37 | 2.6 MB |
Importing external assets | 4:27 | 5.1 MB |
Drawing in Blend | 5:13 | 5.4 MB |
Creating and managing colors | 6:05 | 6.8 MB |
Integrating 3D content | 6:47 | 12.6 MB |
Layout controls | 5:41 | 6.6 MB |
Text controls | 2:21 | 2.2 MB |
User input controls | 1:39 | 1.3 MB |
Other WPF controls | 4:35 | 8.9 MB |
Animation basics | 8:28 | 12.1 MB |
Creating animated buttons | 10:49 | 12.8 MB |
Animating in 3D | 4:32 | 8 MB |
Binding to WPF controls | 5:35 | 9.9 MB |
Binding to external data sources | 6:23 | 9.9 MB |
Laying out the application | 5:54 | 7.9 MB |
Integrating the Flickr RSS data | 7:47 | 9.9 MB |
Customizing the ListBox | 8:43 | 14.4 MB |
Binding to the data | 5:32 | 10.9 MB |
Publishing with Visual Studio | 5:11 | 9.7 MB |
Other WPF resources | 2:47 | 5.5 MB |
URL Rewriting with URLRewriter.Net
URL Rewriting has lots of benefits, listing its main benefits
<configuration>
<configSections>
<section name="rewriter"
requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<rewriter>
<rewrite url="~/Article/(.+)-(.+).aspx" to="~/DynamicPage.aspx?MyTitleId=$2"/>
</rewriter>
</configuration>
public static string GenerateURL(object Title, object strId)
{
string strTitle = Title.ToString();
#region Generate SEO Friendly URL based on Title
//Trim Start and End Spaces.
strTitle = strTitle.Trim();
//Trim "-" Hyphen
strTitle = strTitle.Trim('-');
strTitle = strTitle.ToLower();
char[] chars = @"$%#@!*?;:~`+=()[]{}|\'<>,/^&"".".ToCharArray();
strTitle = strTitle.Replace("c#", "C-Sharp");
strTitle = strTitle.Replace("vb.net", "VB-Net");
strTitle = strTitle.Replace("asp.net", "Asp-Net");
//Replace . with - hyphen
strTitle = strTitle.Replace(".", "-");
//Replace Special-Characters
for (int i = 0; i < chars.Length; i++)
{
string strChar = chars.GetValue(i).ToString();
if (strTitle.Contains(strChar))
{
strTitle = strTitle.Replace(strChar, string.Empty);
}
}
//Replace all spaces with one "-" hyphen
strTitle = strTitle.Replace(" ", "-");
//Replace multiple "-" hyphen with single "-" hyphen.
strTitle = strTitle.Replace("--", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("-----", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("--", "-");
//Run the code again...
//Trim Start and End Spaces.
strTitle = strTitle.Trim();
//Trim "-" Hyphen
strTitle = strTitle.Trim('-');
#endregion
//Append ID at the end of SEO Friendly URL
strTitle = "~/Article/" + strTitle + "-" + strId + ".aspx";
return strTitle;
}
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" Width="788px">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<Columns>
<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:HyperLink ID="hlTitle" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Title")%>' NavigateUrl='<%#GenerateURL(DataBinder.Eval(Container.DataItem,"Title"),DataBinder.Eval(Container.DataItem,"Id"))%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblDesc" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Description")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<img src="Images/article.gif" />
<img src="../Images/article.gif" />
Download Source-Code for URL Rewriting
Generate SEO Friendly URL from given string in C# for Asp.net Web Application.
Example 1: Simple Test
Test your Regular Expression with Regular Expression Tester. Checking your .net regular expression would be easy with Regular Expression Tester.
Regular Expression Tester
List of Free Web Services in .Net, this are some basic utility web services.
New to web service and want to know how you can use web service with your .Net Code
IIS 7.0 Easy Tutorial
Start up article on IIS 7 Part 1
Start up article on IIS 7 Part 2
Indeed.com a good website to find
A Comparision research from Indeed.com
Salary of Moss Developer In New York, Ny 10001
$112,000
Salary of Asp.net Developer In New York, Ny 10001
$99,000
Salary of C# Developer In New York, Ny 10001
$104,000
Salary of Wcf In New York, Ny 10001
$111,000
So now search jobs on Best Job Search Engine that which Technology is hot in market and which technology can earn you more. Which Technology others are adopting... I feel asp.net is loosing its charm due to high avaibility!!! But it is most stable technology based on number of jobs available.
I found Indeed.com is good search engine to get update on IT Market, rather than relying on News especially which are more general.
Accordion AJAX Control Example to Create AccordionPane Runtime with Data from Database.
Accordion Control is one of the best AJAX Control as we can use in many different ways to serve our needs. Please refer to this video if you are new to Accordion AJAX Control.
Many time we generate Menu Runtime for that we make use of Treeview Control, but with this example you will understand how Accordion AJAX Control is better than other solution. In this example I have fetch the Country wise data from Northwind Customer Table and display Customer Information CountryWise.
Example 1: Displaying All the customer group by country, belgium
Example 2: Displaying All the customer group by country, brazil
Note: here the content portion is not showing actual customer Id, but you can display easily using the same way i have used to display countries and attach a querystring to display customer information. This piece of code is reusable.
On .aspx page, declare Accordion control.
<asp:Panel ID="pnlShowCountry" runat="server">
<cc1:Accordion ID="acc" runat="server" SelectedIndex="0" AutoSize="none" FadeTransitions="false" FramesPerSecond="50" TransitionDuration="10" HeaderCssClass="AccordionPaneHeaderCSS" ContentCssClass="AccordionPaneContentCSS">
</cc1:Accordion>
</asp:Panel>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
protected void Page_Load(object sender, EventArgs e)
{
PopulateCountry();
}
private void PopulateCountry()
{
DataTable dtCountry = GetCountry();
DataRow drCountry;
string CountryName, CountryCount;
for(int i=0;i< dtCountry.Rows.Count;i++)
{
drCountry = dtCountry.Rows[i];
CountryName = drCountry["CountryName"].ToString();
CountryCount = drCountry["CountryCount"].ToString();
Label lblHeader = new Label();
lblHeader.ID = "lblHeader" + i.ToString();
lblHeader.Text = "<a href='' onclick='return false;' Class='AccordionLink'>" + CountryName + "</a> (" + CountryCount + ")";
//For Content
int iCountryCount = Convert.ToInt16(drCountry["CountryCount"]);
Label lblContent = new Label();
lblContent.ID = "lblContent" + i.ToString();
for (int j = 1; j <= iCountryCount; j++)
{
if(j==1)
lblContent.Text = "<a href='' onclick='return false;' Class='AccordionLink'>Customer " + j.ToString() + "</a><br>Blah Blah Blah....<br>Blah Blah Blah....Blah Blah Blah....";
else
lblContent.Text = lblContent.Text + "<br><a href='' onclick='return false;' Class='AccordionLink'>Customer " + j.ToString() + "</a><br>Blah Blah Blah....<br>Blah Blah Blah....Blah Blah Blah....";
}
AccordionPane accp = new AccordionPane();
accp.ID = "accp" + i.ToString();
accp.HeaderContainer.Controls.Add(lblHeader);
accp.ContentContainer.Controls.Add(lblContent);
acc.Panes.Add(accp);
}
pnlShowCountry.Controls.Add(acc);
}
private DataTable GetCountry()
{
string strConn = ConfigurationManager.AppSettings["connStr"].ToString();
SqlConnection conn = new SqlConnection(strConn);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("select Country as 'CountryName', count(customerId) as 'CountryCount' from customers group by country",conn);
DataSet ds = new DataSet();
da.Fill(ds,"Country");
DataTable dtCountry = ds.Tables["Country"];
return dtCountry;
}