Archive

Archive for October, 2006

Eid Mubarik to All !

October 24, 2006 1 comment

So it’s Chand Raat (New Moon Night) here in Pakistan before the great Religious Eve of Eid-Ul-Fitr in 1427 A.H (Islamic Hijri Year) which marks the end of Holy Month of Ramadan, and the time is 1:51 A.M. This is one great day for Muslims for it’s congregational importance and is sort of gift for us bestowed by Allah according to our belief.

So Eid Mubarik to all the muslims and human in the world. May we undestand true meaning of this day and spread Islamic Essence with accomplishment. Also good Divali wishes to all the Hindus out there in the world 😀

Shoaib and Asif will miss the ICC Champions Trophy

October 17, 2006 2 comments

So another blow to Pakistani Cricket when Paki Paceman Shoaib and New Ball Bowler M. Asif were tested positive for prohibitted anabolic steroid Nandrolone during an internal dope test carried out by the Pakistan Cricket Board. They both reached Pakistan the other night and hence will miss the complete Champions Trophy.

Already Pakistan is suffering from strange happenings since the last test in England, but this is the most comprehensive blow to Pakistani team. I hope Pakistan perform well in the trophy thought it seems impossible 😉

Categories: General

A year gone – 8th October – The Persistance Day !

October 9, 2006 3 comments

So 8th October came once again, but this time it was some thing really special. Yes, one year of the worst ever natural disaster (Earth Quake in Pakistan, specially in Northern Areas and Independent Kashmir of magnitude 7.6 at Richter scale) completed. Well this was one sadest and most terrible and horrible incident in Pakistan’s history. This day is also memorable to me also in that, it showed to world that this third world country, this country with lesser literacy rates, this nation with all the frauds and problems have a really, really big heart. This day we all witnessed that we can also work for our fellow country men without any reward (except some black sheep). As this day bring tears from heart and eyes, it fills us with joy that we will be together ever in any calamity. All I pray is that all the sufferings of effected are gone, and they get back to proper prosperous life by all the means possible. Long Live Pakistan!

How to check which control has caused Post Back !

October 9, 2006 13 comments

My this post will be how to get the control that caused the Post back in ASP.NET code behind. I got this help from this page, all my courtesies to this guy :).

We will have to access the __EVENTTARGET element of the form. If any one has ever seen a client side HTML source of server side HTML code he/she must be familiar with __EVENTTARGET. A hidden tag is added to the form named __EVENTTARGET after a postback. This hidden input is set to the name of the control that was clicked in the __doPostBack JavaScript function(causing postback) and then the form is submitted. We can access this hidden input from our code-behind as it is submitted with the form and can be found in the Params or Form collections. This is how we get the control that caused a postback. Once we have the name you can get a reference to the control via FindControl and use it as needed.

string ctrlname = page.Request.Params.Get(“__EVENTTARGET”);
if (ctrlname != null && ctrlname != string.Empty)
{
return this.Page.FindControl(ctrlname);
}

The only problem of this method is if post back is caused by a button control. This is because a button is rendered as an input type=”submit” tag, and this causes the form to submit only, so a post back is not occured. Thus button will be added to the form collection of the page. So we can get this very control by a little bit of programming logic. So the code will be some like follows.

public static Control GetPostBackControl(Page page)
{
Control control = null;

string ctrlname = page.Request.Params.Get(“__EVENTTARGET”);
if (ctrlname != null && ctrlname != string.Empty)
{
control = page.FindControl(ctrlname);
}
else
{
foreach (string ctl in page.Request.Form)
{
Control c = page.FindControl(ctl);
if (c is System.Web.UI.WebControls.Button)
{
control = c;
break;
}
}
}
return control;
}

This method takes a parameter which is a reference to the Page, it then uses that to look for the control that caused the postback. You can easily use this as follows:

Control c = PageUtility.GetPostBackControl(this.Page);
if (c != null)
{
//…
}