ali raza

C#, .Net ,Asp.net and my thoughts

Monthly Archives: April 2008

How to remove duplicate from string array in .net

In one case i have to right a method to remove duplication from array of strings. 
i write this code 

Public Function RemoveDuplicates(ByVal items As String()) As String()
    Dim noDupsArrList As New ArrayList()
    For i As Integer = 0 To items.Length - 1
        If Not noDupsArrList.Contains(items(i).Trim()) Then
            noDupsArrList.Add(items(i).Trim())
        End If
    Next
    
    Dim uniqueItems As String() = New String(noDupsArrList.Count - 1) {}
    noDupsArrList.CopyTo(uniqueItems)
    Return uniqueItems
End Function

What is Kerbala! In the eye of Leaders of the World.

Charles Dickens said the following about Imam Hussain (AS):

“If Hussain fought to quench his worldly desires, then I do not understand why his sisters, wives and children accompanied him. It stands to reason therefore that he sacrificed purely for Islam.”
Sir Muhammad Iqbal says:
Imam Husayn uprooted despotism forever till the Day of Resurrection. He watered the dry garden of freedom with the surging wave of his blood, and indeed he awakened the sleeping Muslim nation. If Imam Husayn had aimed at acquiring a worldly empire, he would not have traveled the way he did (from Medina to Karbala). Husayn weltered in blood and dust for the sake of truth. Verily he, therefore, became the bed-rock (foundation) of the Muslim creed; la ilaha illa Allah (There is no god but Allah).
Ronay wala hoon Shaheed-e-Kerbala key gham men main,
Kya durey maqsad na dengey Saqiye Kausar mujhey

I am one who weeps at the plight of the Martyr of Kerbala Won’t the reward be given to me by the Keeper of Kauser Allama Iqbal in his Baqiyat (in Urdu)

Thomas Carlyle has relayed this about the Tragedy of Karbala:

“The best lesson which we get from the tragedy of Karbala is that Hussain and his companions were the rigid believers of God. They illustrated that numerical superiority does not count when it comes to truth and falsehood.The victory of Hussain despite his minority marvels me!”

Dr. K. Sheldrake on Imam Hussain (AS) said this:

“Hussain marched with his little company not to glory, not to power or wealth, but to a supreme sacrifice and every member of that gallant band, male and female, knew that the foes were implacable, were not only readyto fight but to kill. Denied even water for the children, they remained parched under a burning sun, amid scorching sands yet no one faltered for a moment and bravely faced the greatest odds without flinching.”


BrownBrown in his `A Literary History of Persia’ writes:
As a reminder, the blood-stained field of Karbala’ where the grandson of the Apostle of God fell at length, tortured by thirst and surrounded by the bodies of his murdered kinsmen, has been at any time since then sufficient to evoke, even in the most lukewarm and heedless, the deepest emotion, the most frantic grief and the exaltation of spirit before which pain, danger, and death shrink to unconsidered trifles. Yearly, on the tenth day of Muharram, the tragedy is rehearsed in Persia, in India, in Turkey, in Egypt, wherever a Shiite community or colony exists; … As I write it all comes back; the wailing chant, the sobbing multitudes, the white raiment red with blood from self-inflicted wounds, the intoxication of grief and sympathy.

World famous Arab historian al-Fakhri has said this about Imam Hussain’s sacrifice:

“This is a catastrophe whereof I care not to speak at length, deeming it alike too grievous and too horrible. For verily, it was a catastrophe than that which naught more shameful has happened in Islam…There happened therein such a foul slaughter as to cause man’s flesh to creep with horror. And again I have dispersed with my long description because ofit’s notoriety, for it is the most lamented of catastrophes.”

KHWAJA MOINUDDIN CHISTI (RA)says

Shah ast Hussain, Badshah ast Hussain,
Deen ast Hussain, Deen Panah ast Hussain,
Sar dad, na dad dast, dar dast-e-yazeed,
Haqaa key binaey La ila ast Hussain
Hussain is the Master, Hussain is the King,
Hussain is Faith, Hussain is Refuge for the Faith,
He gave his head but not his hand in Yazeed’s hand
Hussain is the foundation of La’Illah.

reference : http://wajahatabbas.wordpress.com/2006/02/21/what-is-kerbala-in-the-eye-of-leaders-of-the-world-2/

Seasons Of Life

Life at any time can become difficult.
Life at any time can become easy.

Good or Bad, they are seasons of life.
It all depends upon, how you take on life and adjust to these seasons.

 

reference : http://pravstalk.com

My blog on Creative pakistan web site

link of my weblog appears on creative pakistan website in the category of weblogs

http://www.creative-pakistan.com/cp-home/?cat=9

 

How to filter uploader control using client side script in asp.net

For any client side action we have to choose a scripting language to build our logic. Let us go for JavaScript. When use a file control we have to use a button control for doing the uploading action. It is better to refer to Anand’s article CodeSnip: Working with FileUpload Control to get the basic idea of using FileUpload control.

Then at the button Client event we have to add some JavaScript action to do the filtering action. We have to use the “OnClientClick” event of a <asp:Button /> control. The code is given below.

Listing 2: OnClientClick

<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload"
Width="64px" OnClientClick="return CheckForTestFile();" />

Now our objective is to put the filtering logic in CheckForTestFile() JavaScript function. For this action, copy and paste the following code inside your <HEAD> tag of aspx page.

Listing 3: JS Filter function

<script language="javascript">  
  //Trim the input text
  function Trim(input)
  {
    var lre = /^\s*/; 
    var rre = /\s*$/; 
    input = input.replace(lre, ""); 
    input = input.replace(rre, ""); 
    return input; 
   }
 
   // filter the files before Uploading for text file only  
   function CheckForTestFile() 
   {
        var file = document.getElementById('<%=fileDocument.ClientID%>');
        var fileName=file.value;        
        //Checking for file browsed or not 
        if (Trim(fileName) =='' )
        {
            alert("Please select a file to upload!!!");
            file.focus();
            return false;
        }
 
       //Setting the extension array for diff. type of text files 
       var extArray = new Array(".txt", ".doc"".rtf"".pdf"".sxw", ".odt", 
                                ".stw", ".html"".htm"".sdw"".vor");      
 
       //getting the file name
       while (fileName.indexOf("\\") != -1)
         fileName = fileName.slice(fileName.indexOf("\\"+ 1);
 
       //Getting the file extension                     
       var ext = fileName.slice(fileName.indexOf(".")).toLowerCase();
 
       //matching extension with our given extensions.
       for (var i = 0; i < extArray.length; i++) 
       {
         if (extArray[i] == ext) 
         { 
           return true;
         }
       }  
         alert("Please only upload files that end in types:  " 
           + (extArray.join("  ")) + "\nPlease select a new "
           + "file to upload and submit again.");
           file.focus();
           return false;                
   }    
</script>

Let us go through the codes. The Trim() function would trim the input text. Therefore, in the above code we first check whether there is any file selected in FileUpload control or not. Then we parse the file name with the path to the file-name of the input file using the slice() method of JavaScript which takes the index as input. After getting the file we will still continue parsing to get the file extension out from the File name. Then we iterate a loop to match the input extension with the defeat extensions of our interest stored in an array. If the input extension does not match with any one of the given extension,s we show the alert message and return false as status. This does not allow us to Upload the file and give us a alert message to fetch a file with the given extensions.

 

reference : http://aspalliance.com/1614_Adding_Filter_Action_to_FileUpload_Control_of_ASPNET_20.1

A beatifull song from jumka jan