Aleem’s Weblog

Entries from December 2007

Using ASP.NET AJAX Accordion Control with Sitemap

December 31, 2007 · 17 Comments

ASP.NET AJAX accordion control is a wonderful control made of collapsible panels with an animation effect. Accordion control is mostly used for long content pages with various collapsible sections. The control can also be used as a site menu, collapsible panels gives a very good effect when accordion is used as a site menu.

In ASP.NET any menu control needs to be attached to the web.sitemap file to display the site navigation. Although accordion control does not provide this facility by default as the ASP.NET TreeView control (Accordion cannot be directly binded to SiteMapDataSource object as TreeView) but it is fairly simple to achieve that.

You need to drop a SiteMapDataSource object on the page and then bind the accordion control with the SiteMapNodeCollection instead of SiteMapDataSource. Get the SiteMapNodeCollection from SiteMapDataSource as follows and bind to the accordion control.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim siteMapView As SiteMapDataSourceView = CType(SiteMapDataSource1.GetView(String.Empty), SiteMapDataSourceView)
Dim nodes As SiteMapNodeCollection = CType(siteMapView.Select(DataSourceSelectArguments.Empty), SiteMapNodeCollection)
Accordion1.DataSource = SiteMapNodeCollection
Accordion1.DataBind()
End If
End Sub

In the aspx page add a repeater control in the <contenttemplate> of the accordion control to show the child items in the collapsible panel. The header of the accordion will show the first level nodes from the sitemap and the collapsible panel will show the child nodes of the header item.

<cc1:Accordion ID=”Accordion1″ runat=”server” SelectedIndex=”0″ FadeTransitions=”false”
FramesPerSecond=”40″ TransitionDuration=”250″ AutoSize=”None” RequireOpenedPane=”true”
SuppressHeaderPostbacks=”true” HeaderCssClass=”AccordionHeaderCssClass”>
<HeaderTemplate>
<a class=”AccordionSideBarLink” href=’<%# Eval(“url”) %>’>
<%# Eval(“title”) %>
</a>
</HeaderTemplate>
<ContentTemplate>
<table>
<asp:Repeater ID=”Repeater1″ runat=”server”>
<ItemTemplate>
<tr>
<td id=”AccordionSideBarItem”>
<a class=”AccordionSideBarItemLink” href=”<%# CType(Container.DataItem, System.Web.SiteMapNode).Url %>”>
<%#CType(Container.DataItem, System.Web.SiteMapNode).Title%>
</a>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ContentTemplate>
</cc1:Accordion>

In order to bind the repeater control with the child nodes, add the following code in the Accordion DataBound control.

Protected Sub Accordion1_DataBound(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionItemEventArgs) Handles Accordion1.ItemDataBound
If CType(e, AjaxControlToolkit.AccordionItemEventArgs).ItemType = AjaxControlToolkit.AccordionItemType.Content Then
Dim cPanel As AjaxControlToolkit.AccordionContentPanel = e.AccordionItem
Dim rptr As System.Web.UI.WebControls.Repeater = CType(cPanel.Controls(1), System.Web.UI.WebControls.Repeater)

Dim sNode As System.Web.SiteMapNode = CType(CType(e, AjaxControlToolkit.AccordionItemEventArgs).AccordionItem.DataItem, System.Web.SiteMapNode)
Dim childNodes As System.Web.SiteMapNodeCollection = sNode.ChildNodes
If Not childNodes Is Nothing AndAlso childNodes.Count > 0 Then
rptr.DataSourceID = Nothing
rptr.DataSource = childNodes
rptr.DataBind()
End If
End If
End Sub

and this is how my web.sitemap is arranged.

<?xml version=”1.0″ encoding=”utf-8″ ?>
<siteMap xmlns=”
http://schemas.microsoft.com/AspNet/SiteMap-File-1.0″ enableLocalization=”true”>

<siteMapNode url=”~/Login/Main.aspx” title=”$resources: SiteMap, ServicesHome” description=”" ImageUrl=”~/App_Themes/Standard/Images/ServicesHome_Small.gif” >

.
.
.
<siteMapNode url=”" title=”$resources: SiteMap, Licenses” description=”" ImageUrl=”~/App_Themes/Standard/Images/Licenses_Small.gif” EntityName=”LicenseBox” >
<siteMapNode url=”javascript:openWindow(‘../License/License.aspx?mode=new’,950,600,’License’)” title=”$resources: SiteMap, NewLicense” description=”" EntityName=”License” AccessType=”new”/>
<siteMapNode url=”javascript:openWindow(‘../LicenseRenewal/LicenseRenewal.aspx?mode=new’,950,600,’LicenseRenewal’)” title=”$resources: SiteMap, RenewLicense” description=”" EntityName=”LicenseRenewal” AccessType=”new”/>
<siteMapNode url=”javascript:openWindow(‘../LicenseCancel/LicenseCancel.aspx’,950,600,’LicenseCancel’)” title=”$resources: SiteMap, CancelLicense” description=”" EntityName=”LicenseCancel” AccessType=”new”/>
<siteMapNode url=”javascript:openWindow(‘../LicenseAmmendment/LicenseAmmendment.aspx’,950,600,’LicenseAmmendment’)” title=”$resources: SiteMap, AmmendLicense” description=”" EntityName=”LicenseAmmendment” AccessType=”new”/>
<siteMapNode url=”~/License/LicenseListing.aspx” title=”$resources: SiteMap, ExistingLicenses” description=”" EntityName=”LicenseListing”/>
<siteMapNode url=”javascript:openWindow(‘../Documents/Licensing Department Conditions.pdf’,950,600,’LicenseHelp’)” title=”$resources: SiteMap, LicenseHelp” description=”" EntityName=”Help” />
</siteMapNode>
.
.
.
</siteMapNode>
</siteMap>

Categories: ASP.NET Development · Microsoft

Daughter of the West (by Tariq Ali)

December 31, 2007 · Leave a Comment

A wonderful piece by Tariq Ali which provides insights in the politics of Bhutto family and the overall pakistani politics which is run and manipulated by USA using the political and miltary forces in pakistan. The connections between the two military dictaors Zia and Musharraf, the Al-Zulfiqar group, the hijacking of a plane by Bhutto brothers, how Murtaza Butto later was killed by the ruling government of his own sister and how Pakistan has now again went down the same road it did in Zia’s period and afterwards.

The same author wrote a short piece in guardian after her death.

Another piece from today in belfast telegraph My heart bleeds for pakistan. It deserves better than this grotesque feudal charade.

Categories: Pakistan · Personal Thoughts · Politics

Benazir Bhutto’s Assasination

December 31, 2007 · Leave a Comment

I have been thinking of writing something but after the initial shock and anger subsided, the realization of the consequences of this tragedy for pakistan were so distressing that I could not made up my mind to write.

I have never liked Benzair as a politician as I have grown up in a time when she failed to deliver anything to people of pakistan in her two times at office and she and her controversial husband have been at the center of allegations of corruptions which I believe are true in most cases. However, her death a couple of days ago made me (and a lot of other people) realize the importance she had at this point for Pakistan, a country which is struggliung for survival.

She was the only prominent and mature leader and at this point even a corrupt benazir would have been a better option to keep the country together than the foolish and corrupt militry generals who have brought the country at the brink of destruction yet again. In a bid to keep implementing US policy and maintaining power, they have again (as in Zia-Ul-Haq’s tme) defied the civil forces of the society and have caused anger and disappointment in people and it is not long that thier US allys will dump them again.

Although blame has been placed on “Al-Qaeda” and “Militant Extremists” which is the most convinient and is a trademark of US government and its ally, the pakistani military, but anyone with slightest concious can tell that it is the work of pakistani intelligence agencies, and proving my point government has itself made a mockery of itself by suggesting a bizzare death by collision with sunroof of the vehicle. This claim has been clearly nulllified after the emergence of new videos which clearly show that she was shot.

The United States is now left with practically no options for pakistan. As Tariq Ali points out in one of his articles, this arranged power wedding between benazir and military was not a good idea from the start and now it has left the US state department and policy makers in disarray.

Ofcourse, no one can fill benazir shoes easily, but there was still hope for pakistan if PPP had nominated a mature and respected politician like Aitezaz Ahsan who had the chances of getting credible support from the masses and civil socitey and could have brought some form of democracy and normalcy to the country but nature seems not so merciful on the land of Jinnah and Iqbal. Ironically, Mr. Zardari, the most controversial figure in politics of pakistan who has pending corruption cases in many countries has become the leader of the party and in the longer run the fate of the country and its people has been left at the hands of a 19-year old who has hardly spend time in pakistan.

I don’t see any other candidate other than Aitezaz Ahsan who if made the PPP candidate for PM could have brought some credible democracy to this country. Any other selection like PML(Q), PML(N), Zardari or Amin Fahim is likely to create more allienation among provinces and the people and will stimulate the army to conquer the country again in a few years.

Note: Imran Khan is also a credible opiton, but he does not have a strong grass root party like PPP which is very important to muster support from the large percentage of illetrate masses of pakistan. Imran is only known and respected among the educated youth who unfortunately constitute a very small group.

Categories: Pakistan · Personal Thoughts · Politics

Dr. Hoodbhoy’s Commandments for United States and the Muslim World

December 13, 2007 · Leave a Comment

Excerpts from Professor Hoodbhoy’s lecture.

http://pakistaniat.com/2007/12/12/pervez-hoodbhoy-on-us-and-them-mindset/

Wondeful article.

Categories: Pakistan · Personal Thoughts · Politics

Freedom or Safety ?

December 13, 2007 · 1 Comment

There have been all sorts of opinions, emails, comments and various articles floating on the internet after the imposition of emergency in Pakistan. A lot of these writings are rightly against the current lawlessness and complete anarchy displayed by the government. However, very interestingly some people still support these non-democratic and lawless actions. (I cannot understand why? but probably becuase some people might have thought the same about me when I have had good opinion for the military government before 2007).

One of the mails which I got recently about the support for closing down GEO TV had the following line in the text and It made me understand that people who say that we are a dead nation might be correct.

“A COUNTRY where 60 percent of population cannot read and has never been to school, the media must not be free”

I was grieving at the irony that how the slavery of our ancestors for centuries has even taken away the feeling of freedom and the understanding of what it means to be free. I think Quaid-e-Azam and Iqbal must be crying in thier graves that they have fought for people who do not even undertand the meaning of freedom.

There is an inherent reluctance of pakistani society to become free; they continuously want to live in a safe glass house which our enemies (including foriegn powers) and our friends (pakistani army) has built together so they can continue benefiting form the common man of our society. YES the common man is illiterate and may have less ability of selection but this does not take away his right of freedom. If this was the case the Muslims of India which were largely uneducated and of lesser educational and technical abilities would have been denied freedom. Unfortunately, today we are opposing the very basis on which this country was built. And Why? becuase we do not wish to be free but to be safe as we have been made to believe these two concepts are opposite to each other.

If you want safety by the Army, you do not need to be free. If you want to be free then we are not providing  any saftey. (I wish if the second option was available; I would have taken it). I choose freedom for which our forefathers died over the so called safety which our saviours (Army) are providing us.

As a patriotic pakistani I have been most hurt in recent times by the comments made by our COAS (the post powerful office of our unfortunate country). As Mr. Musharraf blunted out his mind infront of international media that

“Do not expect Freedom for Pakistan, Do not expect Human Rights in Pakistan as rest of the world. We know how we can “control” our own people.”

I felt like crying as if this country was given to us in some charity becuase we the illiterate pakistanis do not have the right of freedom or human rights like the rest of the world and can only be controlled like animals of Jungle.

And then again at the prestigous ceremony as his final day as the head of Pakistan Armed Forces. Mr. Musharraf said “This country cannot exist without this Army” and I could not help but to get disgutsed and distressed by our ill fate that the saviors (Army) of this country believe that the country exists becuase of them; and not that they exist becuase of this country.

All this is becuase the common man like me, you and all of us are reluctant to be free becuase we choose our safety.

It is becuase of people like us that make compromises of freedom for the materialistic gains that nations are forgotten in history. But again this is how the world works and we have choosen the path to be forgotten, not the path to be remembered !

Categories: Pakistan · Personal Thoughts · Politics