Monday, 25 March 2013

Get the Private/Local IP Address of Your Machine Using C#.Net


Get the Private/Local IP Address of Your Machine Using C#.Net


Here is how you can get the Local IP Address of your machine using ASP.NET...


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Local IP</title>
    
<script type="text/javascript">

     window.onload = function () {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "http://jsonip.appspot.com/?callback=DisplayIP";
        document.getElementsByTagName("head")[0].appendChild(script);
    };
    function DisplayIP(response) {
        document.getElementById("ipaddress").innerHTML = "Your Public IP Address is " + response.ip;
    } 

</script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        <span id = "ipaddress"></span>
    </div>
    </form>
</body>
</html>

Code-Behind:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Net.NetworkInformation;

public partial class LocalIpAddress : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
        {
            if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
            {
                Console.WriteLine(ni.Name);
                foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
                {
                    if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    {
                       Label1.Text=ip.Address.ToString();
                    }
                }
            }
        }
    }
}

Wednesday, 20 March 2013

Check the Default Browser Language Using Javascript [Compatible with IE]


Check the Default Browser Language Using JavaScript [Compatible with IE]


Check The Default Language of Client Browser using the following JavaScript... 

Note: This works in IE only.



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>User Language</title>
    
    <SCRIPT LANGUAGE="JavaScript">

//Works in Internet Explorer

<!-- Begin
if (navigator.browserLanguage.substr(0,2) == "af")
  document.write('Afrikaans')
else if (navigator.browserLanguage.substr(0,2) == "ar")
{
 if (navigator.browserLanguage.substr(3,2) == "ae")
  document.write('Arabic / United Arab Emirates')
 else if (navigator.browserLanguage.substr(3,2) == "bh")
  document.write('Arabic / Bahrain')
 else if (navigator.browserLanguage.substr(3,2) == "eg")
  document.write('Arabic / Egypt')
 else if (navigator.browserLanguage.substr(3,2) == "dz")
  document.write('Arabic / Algeria')
 else if (navigator.browserLanguage.substr(3,2) == "iq")
  document.write('Arabic / Iraq')
 else if (navigator.browserLanguage.substr(3,2) == "jo")
  document.write('Arabic / Jordan')
 else if (navigator.browserLanguage.substr(3,2) == "kw")
  document.write('Arabic / Kuwait')
 else if (navigator.browserLanguage.substr(3,2) == "lb")
  document.write('Arabic / Lebanon')
 else if (navigator.browserLanguage.substr(3,2) == "ly")
  document.write('Arabic / Libya')
 else if (navigator.browserLanguage.substr(3,2) == "ma")
  document.write('Arabic / Morocco')
 else if (navigator.browserLanguage.substr(3,2) == "om")
  document.write('Arabic / Oman')
 else if (navigator.browserLanguage.substr(3,2) == "qa")
  document.write('Arabic / Qatar')
 else if (navigator.browserLanguage.substr(3,2) == "sa")
  document.write('Arabic / Saudi Arabia')
 else if (navigator.browserLanguage.substr(3,2) == "sy")
  document.write('Arabic / Syria')
 else if (navigator.browserLanguage.substr(3,2) == "tn")
  document.write('Arabic / Tunisia')
 else if (navigator.browserLanguage.substr(3,2) == "ye")
  document.write('Arabic / Yemen')
 else document.write('Arabic')
}
else if (navigator.browserLanguage.substr(0,2) == "be")
  document.write('Belarusian')
else if (navigator.browserLanguage.substr(0,2) == "bg")
  document.write('Bulgarian')
else if (navigator.browserLanguage.substr(0,2) == "ca")
  document.write('Catalan')
else if (navigator.browserLanguage.substr(0,2) == "cs")
  document.write('Czech')
else if (navigator.browserLanguage.substr(0,2) == "da")
  document.write('Danish')
else if (navigator.browserLanguage.substr(0,2) == "de")
{
 if (navigator.browserLanguage.substr(3,2) == "at")
  document.write('German / Austria')
 else if (navigator.browserLanguage.substr(3,2) == "ch")
  document.write('German / Switzerland')
 else if (navigator.browserLanguage.substr(3,2) == "li")
  document.write('German / Liechtenstein')
 else if (navigator.browserLanguage.substr(3,2) == "lu")
  document.write('German / Luxembourg')
else document.write('German / Germany')
}
else if (navigator.browserLanguage.substr(0,2) == "el")
  document.write('Greek / Greece')
else if (navigator.browserLanguage.substr(0,2) == "en")
{
 if (navigator.browserLanguage.substr(3,2) == "us")
  document.write('English / United States')
 else if (navigator.browserLanguage.substr(3,2) == "au")
  document.write('English / Austrailia')
 else if (navigator.browserLanguage.substr(3,2) == "bz")
  document.write('English / Belize')
 else if (navigator.browserLanguage.substr(3,2) == "ca")
  document.write('English / Canada')
 else if (navigator.browserLanguage.substr(3,2) == "gb")
  document.write('English / Great Britain')
 else if (navigator.browserLanguage.substr(3,2) == "ie")
  document.write('English / Ireland')
 else if (navigator.browserLanguage.substr(3,2) == "jm")
  document.write('English / Jamaica')
 else if (navigator.browserLanguage.substr(3,2) == "nz")
  document.write('English / New Zealand')
 else if (navigator.browserLanguage.substr(3,2) == "tt")
  document.write('English / Trinidad')
 else if (navigator.browserLanguage.substr(3,2) == "za")
  document.write('English / South Africa')
 else document.write('English')
}
else if (navigator.browserLanguage.substr(0,2) == "es")
{
 if (navigator.browserLanguage.substr(3,2) == "ar")
  document.write('Spanish / Argentina')
 else if (navigator.browserLanguage.substr(3,2) == "bo")
  document.write('Spanish / Bolivia')
 else if (navigator.browserLanguage.substr(3,2) == "cl")
  document.write('Spanish / Chile')
 else if (navigator.browserLanguage.substr(3,2) == "co")
  document.write('Spanish / Colombia')
 else if (navigator.browserLanguage.substr(3,2) == "cr")
  document.write('Spanish / Costa Rica')
 else if (navigator.browserLanguage.substr(3,2) == "do")
  document.write('Spanish / Dominican Republic')
 else if (navigator.browserLanguage.substr(3,2) == "ec")
  document.write('Spanish / Ecuador')
 else if (navigator.browserLanguage.substr(3,2) == "gt")
  document.write('Spanish / Guatemala')
 else if (navigator.browserLanguage.substr(3,2) == "hn")
  document.write('Spanish / Honduras')
 else if (navigator.browserLanguage.substr(3,2) == "mx")
  document.write('Spanish / Mexico')
 else if (navigator.browserLanguage.substr(3,2) == "ni")
  document.write('Spanish / Nicaragua')
 else if (navigator.browserLanguage.substr(3,2) == "pa")
  document.write('Spanish / Panama')
 else if (navigator.browserLanguage.substr(3,2) == "pe")
  document.write('Spanish / Peru')
 else if (navigator.browserLanguage.substr(3,2) == "pr")
  document.write('Spanish / Puerto Rico')
 else if (navigator.browserLanguage.substr(3,2) == "py")
  document.write('Spanish / Paraguay')
 else if (navigator.browserLanguage.substr(3,2) == "sv")
  document.write('Spanish / El Salvador')
 else if (navigator.browserLanguage.substr(3,2) == "uy")
  document.write('Spanish / Uruguay')
 else if (navigator.browserLanguage.substr(3,2) == "ve")
  document.write('Spanish / Venezuela')
 else document.write('Spanish / Spain')
}
else if (navigator.browserLanguage.substr(0,2) == "et")
  document.write('Estonian')
else if (navigator.browserLanguage.substr(0,2) == "eu")
  document.write('Basque')
else if (navigator.browserLanguage.substr(0,2) == "fa")
  document.write('Farsi')
else if (navigator.browserLanguage.substr(0,2) == "fi")
  document.write('Finnish')
else if (navigator.browserLanguage.substr(0,2) == "fo")
  document.write('Faeroese')
else if (navigator.browserLanguage.substr(0,2) == "fr")
{
 if (navigator.browserLanguage.substr(3,2) == "be")
  document.write('French / Belgium')
 else if (navigator.browserLanguage.substr(3,2) == "ca")
  document.write('French / Canada')
 else if (navigator.browserLanguage.substr(3,2) == "ch")
  document.write('French / Switzerland')
 else if (navigator.browserLanguage.substr(3,2) == "ca")
  document.write('French / Luxembourg')
 else document.write('French / France')
}
else if (navigator.browserLanguage.substr(0,2) == "gd")
{
 if (navigator.browserLanguage.substr(3,2) == "ie")
  document.write('Gaelic / Ireland')
 else document.write('Gaelic / Scotland')
}
else if (navigator.browserLanguage.substr(0,2) == "he")
  document.write('Hebrew')
else if (navigator.browserLanguage.substr(0,2) == "hi")
  document.write('Hindi')
else if (navigator.browserLanguage.substr(0,2) == "hr")
  document.write('Croatian')
else if (navigator.browserLanguage.substr(0,2) == "hu")
  document.write('Hungarian')
else if (navigator.browserLanguage.substr(0,2) == "in")
  document.write('Indonesian')
else if (navigator.browserLanguage.substr(0,2) == "is")
  document.write('Icelandic')
else if (navigator.browserLanguage.substr(0,2) == "he")
  document.write('Hebrew')
else if (navigator.browserLanguage.substr(0,2) == "it")
{
 if (navigator.browserLanguage.substr(3,2) == "ch")
  document.write('Italian / Switzerland')
 else document.write('Italian / Italy')
}
else if (navigator.browserLanguage.substr(0,2) == "ja")
  document.write('Japanese / Japan')
else if (navigator.browserLanguage.substr(0,2) == "ji")
  document.write('Yiddish')
else if (navigator.browserLanguage.substr(0,2) == "ko")
  document.write('Korean / Korea')
else if (navigator.browserLanguage.substr(0,2) == "lt")
  document.write('Lithuanian / Lithuania')
else if (navigator.browserLanguage.substr(0,2) == "lv")
  document.write('Latvian')
else if (navigator.browserLanguage.substr(0,2) == "mk")
  document.write('Macedonian / Macedonia')
else if (navigator.browserLanguage.substr(0,2) == "ms")
  document.write('Malaysian / Malaysia')
else if (navigator.browserLanguage.substr(0,2) == "mt")
  document.write('Maltese / Malta')
else if (navigator.browserLanguage.substr(0,2) == "nl")
{
 if (navigator.browserLanguage.substr(3,2) == "be")
  document.write('Dutch / Belgium')
 else document.write('Dutch / Netherlands')
}
else if (navigator.browserLanguage.substr(0,2) == "pl")
  document.write('Polish / Poland')
else if (navigator.browserLanguage.substr(0,2) == "pt")
{
 if (navigator.browserLanguage.substr(3,2) == "br")
  document.write('Portuguese / Brazil')
 else document.write('Portuguese / Portugual')
}
else if (navigator.browserLanguage.substr(0,2) == "rm")
  document.write('Rhaeto-Romanic / Romania')
else if (navigator.browserLanguage.substr(0,2) == "ro")
  document.write('Romanian / Romania')
else if (navigator.browserLanguage.substr(0,2) == "ru")
  document.write('Russian / Russia')
else if (navigator.browserLanguage.substr(0,2) == "sb")
  document.write('Sorbian')
else if (navigator.browserLanguage.substr(0,2) == "sk")
  document.write('Slovak')
else if (navigator.browserLanguage.substr(0,2) == "sl")
  document.write('Slovenian')
else if (navigator.browserLanguage.substr(0,2) == "sq")
  document.write('Albanian / Albania')
else if (navigator.browserLanguage.substr(0,2) == "sr")
  document.write('Serbian / Serbia')
else if (navigator.browserLanguage.substr(0,2) == "sv")
{
 if (navigator.browserLanguage.substr(3,2) == "fi")
  document.write('Swedish / Finland')
 else document.write('Swedish / Sweden')
}
else if (navigator.browserLanguage.substr(0,2) == "sx")
  document.write('Sutu')
else if (navigator.browserLanguage.substr(0,2) == "sz")
  document.write('Sami')
else if (navigator.browserLanguage.substr(0,2) == "th")
  document.write('Thai / Thailand')
else if (navigator.browserLanguage.substr(0,2) == "tn")
  document.write('Tswana')
else if (navigator.browserLanguage.substr(0,2) == "tr")
  document.write('Turkish / Turkey')
else if (navigator.browserLanguage.substr(0,2) == "ts")
  document.write('Tsonga')
else if (navigator.browserLanguage.substr(0,2) == "uk")
  document.write('Ukrainian')
else if (navigator.browserLanguage.substr(0,2) == "th")
  document.write('Thai / Thailand')
else if (navigator.browserLanguage.substr(0,2) == "ur")
  document.write('Urdu')
else if (navigator.browserLanguage.substr(0,2) == "ve")
  document.write('Venda')
else if (navigator.browserLanguage.substr(0,2) == "vi")
  document.write('Vietnamese / Vietnam')
else if (navigator.browserLanguage.substr(0,2) == "xh")
  document.write('Xhosa')
else if (navigator.browserLanguage.substr(0,2) == "zh")
{
 if (navigator.browserLanguage.substr(3,2) == "cn")
  document.write('Chinese / China')
 else if (navigator.browserLanguage.substr(3,2) == "hk")
  document.write('Chinese / Hong Kong')
 else if (navigator.browserLanguage.substr(3,2) == "sg")
  document.write('Chinese / Singapore')
 else if (navigator.browserLanguage.substr(3,2) == "tw")
  document.write('Chinese / Taiwan')
 else document.write('Chinese / China')
}
else if (navigator.browserLanguage.substr(0,2) == "zu")
  document.write('Zulu')
else
  document.write('Could not be determined')
//  End -->
</script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

Morse Code Converter Using Javascript


Morse Code Converter Using Javascript


Have You heard about Morse Code?? Ha Ha Ha .. Well It is some kind of secret code used for communication during  WWI and WWII.. Pretty Old Technology but Guess what we can replicate the same using ASP.Net and Javascript....

What is Morse Code?

Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks that can be directly understood by a skilled listener or observer without special equipment. The International Morse Code encodes the ISO basic Latin alphabet, some extra Latin letters, the Arabic numerals and a small set of punctuation and procedural signals as standardized sequences of short and long signals called "dots" and "dashes", or "dits" and "dahs". Because many non-English natural languages use more than the 26 Roman letters, extensions to the Morse alphabet exist for those languages.

Read More Over here.


How can I generate My Own Brand New Morse Code Translator?



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Morse Code Generator</title>
    
    <script type="text/javascript" language="JavaScript">

 var table =
 {
  "A" : ".-",   "K" : "-.-",  "U" : "..-",   "5" : ".....",  "," : "--..--", "$" : "...-..-",
  "B" : "-...", "L" : ".-..", "V" : "...-",  "6" : "-....",  "?" : "..--..", " " : "*",
  "C" : "-.-.", "M" : "--",   "W" : ".--",   "7" : "--...",  "(" : "-.--.",
  "D" : "-..",  "N" : "-.",   "X" : "-..-",  "8" : "---..",  ")" : "-.--.-",
  "E" : ".",    "O" : "---",  "Y" : "-.--",  "9" : "----.",  "-" : "-....-",
  "F" : "..-.", "P" : ".--.", "Z" : "--..",  "0" : "-----",  "\"" : ".-..-.",
  "G" : "--.",  "Q" : "--.-", "1" : ".----", "/" : "-..-.",  "_" : "..--.-",
  "H" : "....", "R" : ".-.",  "2" : "..---", "+" : ".-.-.",  "'" : ".----.",
  "I" : "..",   "S" : "...",  "3" : "...--", "=" : "-...-",  ":" : "---...",
  "J" : ".---", "T" : "-",    "4" : "....-", "." : ".-.-.-", ";" : "-.-.-."
 };

 function go()
 {
  var output = "";
  var input  = document.forms[0].ALPHA.value.toUpperCase();

  for( var i = 0; i < input.length; i++ )
  {
   var temp = table[ input.charAt(i) ];
   if( temp )
   {
    if( "*" == temp )
    {
     temp = " ";
    }
    output += temp + " ";
   }
   else output += "  ";
  }

  document.forms[0].MORSE.value = output;
 }

 function ungo()
 {
  var output = "";
  var input  = document.forms[0].MORSE.value.replace( /   /g, " * " ).split( " " );

  for( var ix = 0; ix < input.length; ix++ )
  {
   for( var key in table )
   {
    if( table[key] == input[ix])
    {
     output += key;
     break;
    }
   }
  }

  document.forms[0].ALPHA.value = output;
 }
</script>
    
</head>
<body>
<h1>Morse Code Translator</h1>
<form name="entree" id="entree">
 <table>
  <tr>
   <td>Alphabet:</td>
   <td><input size="30" type="text" name='ALPHA'></td>
   <td><input type="button" value='To Morse Code' onclick="javascript:go()"></td>
  </tr>
  <tr>
   <td>Morse Code:</td>
   <td><input size="30" type="text" name="MORSE"></td>
   <td><input type="button" value='To Alphabet' onclick="javascript:ungo()"></td>
  </tr>
  <tr>
   <td colspan="3" align="center"><input type="reset" value='Clear All'></td>
  </tr>
 </table>
</form>
</body>
</html>




Create Your Own Custom Lorem Ipsum Generator using Javascript


Create Your Own Custom Lorem Ipsum Generator using Javascript

Well If Your are a Graphics Designer/HTML Designer you might come up to a situation to write some text in the blank HTML template to fill up the gap. You should have browsed over the net to find an online Lorem Ipsum generator to get the dummy para.

But I dont believe in using others tools when I can create my own...



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">

    <title>Lorem Ipsum Generator</title>
    
<script type="text/javascript" language="javascript">
    //<![CDATA[

    function objectTag()
    {
     var lorem = new Array();

     switch( document.theForm.loremString.value )
     {
      case "latin":
      {
    lorem[0] = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
    lorem[1] = "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.";
    lorem[2] = "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.";
    lorem[3] = "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.";
    lorem[4] = "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.";
    lorem[5] = "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.";
    lorem[6] = "Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus.";
       break;
      }
      case "silly":
      {
    lorem[0] = "Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay. Marquee selectus non provisio incongruous feline nolo contendre. Gratuitous octopus niacin, sodium glutimate. Quote meon an estimate et non interruptus stadium.";
    lorem[1] = "Sic tempus fugit esperanto hiccup estrogen. Glorious baklava ex librus hup hey ad infinitum. Non sequitur condominium facile et geranium incognito. Epsum factorial non deposit quid pro quo hic escorol. Marquee selectus non provisio incongruous feline nolo contendre Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum.";
    lorem[2] = "Defacto lingo est igpay atinlay. Marquee selectus non provisio incongruous feline nolo contendre. Gratuitous octopus niacin, sodium glutimate. Quote meon an estimate et non interruptus stadium. Sic tempus fugit esperanto hiccup estrogen. Glorious baklava ex librus hup hey ad infinitum. Non sequitur condominium facile et geranium incognito. Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay. Gratuitous octopus niacin, sodium glutimate.";
    lorem[3] = "Quote meon an estimate et non interruptus stadium. Sic tempus fugit esperanto hiccup estrogen. Glorious baklava ex librus hup hey ad infinitum. Non sequitur condominium facile et geranium incognito.";
       break;
      }
      case "spanish":
      {
       lorem[0] = "Li Europan lingues es membres del sam familie. Lor separat existentie es un myth. Por scientie, musica, sport etc., li tot Europa usa li sam vocabularium. Li lingues differe solmen in li grammatica, li pronunciation e li plu commun vocabules. Omnicos directe al desirabilit&aacute; de un nov lingua franca: on refusa continuar payar custosi traductores. It solmen va esser necessi far uniform grammatica, pronunciation e plu sommun paroles.";
       break;
      }
      case "italian":
      {
       lorem[0] = "Ma quande lingues coalesce, li grammatica del resultant lingue es plu simplic e regulari quam ti del coalescent lingues. Li nov lingua franca va esser plu simplic e regulari quam li existent Europan lingues. It va esser tam simplic quam Occidental: in fact, it va esser Occidental. A un Angleso it va semblar un simplificat Angles, quam un skeptic Cambridge amico dit me que Occidental es."
       break;
      }
     }

        if( "characters" == document.theForm.type.value )
        {
         var outputString = '';
            var numOfChars = document.theForm.numbers.value;
            numOfChars = parseInt( numOfChars );
            var tempString = lorem.join( "\n\n" );
            while ( outputString.length < numOfChars ) outputString += tempString;
            document.forms[0].output.value = outputString.substring(0, numOfChars );
        }
        else if( "words" == document.theForm.type.value )
        {
            var numOfWords = document.theForm.numbers.value;
            numOfWords = parseInt( numOfWords );

            var list = new Array();
            var wordList = new Array();
            wordList = lorem[ 0 ].split( ' ' );
            var iParagraphCount = 0;
            var iWordCount = 0;

            while( list.length < numOfWords )
            {
             if( iWordCount > wordList.length )
             {
              iWordCount = 0;
              iParagraphCount++;
              if( iParagraphCount + 1 > lorem.length ) iParagraphCount = 0;
              wordList = lorem[ iParagraphCount ].split( ' ' );
              wordList[ 0 ] = "\n\n" + wordList[ 0 ];
             }

             list.push( wordList[ iWordCount ] );

             iWordCount++;
            }
            document.forms[0].output.value = list.join( ' ' );
        }
        else
        {
            var numOfParagraphs = document.theForm.numbers.value;
            numOfParagraphs = parseInt( numOfParagraphs );

            var list = new Array();
   var iParagraphCount = 0;

            while( list.length < numOfParagraphs )
            {
             if( iParagraphCount +1 > lorem.length )
             {
              iParagraphCount = 0;
             }

             list.push( lorem[ iParagraphCount ] );
             iParagraphCount++;
            }
            document.forms[0].output.value = list.join( "\n\n" );
        }
    }

    function copypaste()
    {
        document.forms[0].output.focus();
        document.forms[0].output.select();
        therange=document.forms[0].output.createTextRange();
        therange.execCommand("Copy");
    }
    //]]>
</script>


<style type="text/css">

body {
 background-color : white;
 font-family : Arial, Helvetica, sans-serif;
 font-size   : .9em;
 color       : #424037;
 max-width   : 700px;
 padding     : 15px;
 margin      : auto;
}

td {
 font-family : Arial, Helvetica, sans-serif;
 font-size   : .9em;
 color       : #424037;
}

h1, h2 {
 color : #666;
}

a {
 color : #BC7134;
 text-decoration : none;
}

</style>

</head>

<body>
<h1>Lorem Ipsum Generator</h1>
<form name="theForm" action="javascript:objectTag();" id="theForm"><select name="loremString" style="width: 100%;">
<option value="latin" selected="selected">Lorem ipsum dolor sit amet...</option>
<option value="silly">Epsum factorial non deposit quid pro quo...</option>
<option value="spanish">Li Europan lingues es membres del sam familie...</option>
<option value="italian">Ma quande lingues coalesce, li grammatica...</option>
</select><br>
Number of <select name="type">
<option value="characters">Characters</option>
<option value="words" selected="selected">Words</option>
<option value="paragraphs">Paragraphs</option>
</select> <input type="text" name="numbers" value="8" size="6"> <input type="submit" name="btnOK" value="Generate"><br>
<textarea rows="10" name="output" style="width: 100%;">
</textarea>
<br>
<input type="button" onclick="copypaste()" value="Select All"> to clipboard (IE/Windows only)<br>
</body>
</html>




Auto-Redirect Page After Certain Time Period Using Javascript


Auto-Redirect Page After Certain Time Period Using Javascript


Well We always get into situation when we  have to redirect the older page to a new URL after displaying a custom message. This is useful in situations when we purchase a new domain and want to redirect the page to the new domain.

So Here I am with a solution to the above mentioned problem using Javascript:



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Auto-Redirect</title>
    <script type="text/javascript">
    function moveTo() {
  location.href = "http://www.dotnetvishal.com";
}
window.onload=setTimeout('moveTo()', 5000);
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    This page has moved. You shall now be automatically redirected to our new page. If you are not automatically moved <a href="http://www.dotnetvishal.com">Click Here!</a>
    </div>
    </form>
</body>
</html>






Tuesday, 19 March 2013

Add Line Number to Text Using Javascript


Add Line Number to Text Using Javascript


You can add Line Numbers to a text inside a Multiline Textbox/TextArea using the following Javascript:



<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Add Line Number Using Javascript</title>
    
    <script language="JavaScript" type="text/javascript">
        <!--
        function main()
        {
            var test_string = new Array();
            test_string = document.forms[0].inputString.value.split( '\n' );
            var result = "";

   for( var ix = 0; ix < test_string.length; ix++ )
   {
    result += fixNumber( ix, test_string.length ) + test_string[ ix ];
    if( ix != test_string.length - 1)
    {
     result += "\n";
    }
   }
            document.forms[0].output.value = result;
        }

  function fixNumber( ix, total )
  {
   var temp = total.toString();
   var width = temp.length;
   var outputNum = ( ix + 1 ).toString();

   while( outputNum.length < width )
   {
    outputNum = " " + outputNum;
   }

   return outputNum + ": ";
  }
        //-->
</script>
    
</head>
<body>
<h1>Insert Line Numbers</h1>
<form action="javascript:main();">
<textarea cols="100" rows="12" name="inputString">
Lorem
ipsum
dolor
sit
amet,
consetetur
sadipscing
elitr,
sed
diam
nonumy
eirmod</textarea>
<br>
<textarea cols="100" rows="12" name="output"></textarea>
<br>
<input type="Submit"></form>
</body>
</html>






Monday, 11 March 2013

Display DropDownList Item on Mouse Hover Using Javascript


Display DropDownList Item on Mouse Hover Using Javascript


You can display the contents of the dropdownlists on hovering the Mouse Over the dropdown using the following Javascript Code..


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">


<title>Dropdownlist Hover</title>
<script type="text/javascript">


function Open_ddl(ddl) {


document.getElementById(ddl).size = 5


}

function Close_ddl(ddl) {


document.getElementById(ddl).size = 1


}

</script>

</head>
<body>


<form id="form1" runat="server">


<div>


<asp:DropDownList ID="DropDownList1" runat="server" onmouseover="Open_ddl('DropDownList1')"


onmouseout="Close_ddl('DropDownList1')">


<asp:ListItem>--Select--</asp:ListItem>


<asp:ListItem>Vishal</asp:ListItem>


<asp:ListItem>Vivek</asp:ListItem>


<asp:ListItem>Amit</asp:ListItem>


<asp:ListItem>Suresh</asp:ListItem>


</asp:DropDownList>


</div>


</form>
</body>
</html>

Tuesday, 5 March 2013

Convert Number(Integer) To Words(String) Using C# ASP.NET


Convert Number(Integer) To Words(String) Using C# ASP.NET


Most of us often came across this sort of problem when we want to display the integer entered by the User in Words.. This kind of situation mostly arises when we are dealing with Pricing and Billing.. So Here is One Solution to this Problem...

Design Part:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Number to Text</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True" OnTextChanged="TextBox1_TextChanged"></asp:TextBox><br />
        <br />
        <asp:TextBox ID="TextBox2" runat="server" Height="100px" TextMode="MultiLine" Width="600px"></asp:TextBox>
    </div>
    </form>
</body>
</html>

Code Behind:


    protected void Page_Load(object sender, EventArgs e)
    {

    }

     public String changeToWords(String numb)
        {
            String val = "", wholeNo = numb, points = "", andStr = "", pointStr = "";
            String endStr = ("");
            try
            {
                int decimalPlace = numb.IndexOf(".");
                if (decimalPlace > 0)
                {
                    wholeNo = numb.Substring(0, decimalPlace);
                    points = numb.Substring(decimalPlace + 1);
                    if (Convert.ToInt32(points) > 0)
                    {
                        andStr = ("point");// just to separate whole numbers from points/Rupees
                        
                    }
                }
                val = String.Format("{0} {1}{2} {3}", translateWholeNumber(wholeNo).Trim(), andStr, pointStr, endStr);
            }
            catch
            {
                ;
            }
            return val;
        }

        private String translateWholeNumber(String number)
        {
            string word = "";
            try
            {
                bool beginsZero = false;//tests for 0XX
                bool isDone = false;//test if already translated
                double dblAmt = (Convert.ToDouble(number));
                //if ((dblAmt > 0) && number.StartsWith("0"))

                if (dblAmt > 0)
                {//test for zero or digit zero in a nuemric
                    beginsZero = number.StartsWith("0");
                    int numDigits = number.Length;
                    int pos = 0;//store digit grouping
                    String place = "";//digit grouping name:hundres,thousand,etc...
                    switch (numDigits)
                    {
                        case 1://ones' range
                            word = ones(number);
                            isDone = true;
                            break;
                        case 2://tens' range
                            word = tens(number);
                            isDone = true;
                            break;
                        case 3://hundreds' range
                            pos = (numDigits % 3) + 1;
                            place = " Hundred ";
                            break;
                        case 4://thousands' range
                        case 5:
                        case 6:
                            pos = (numDigits % 4) + 1;
                            place = " Thousand ";
                            break;
                        case 7://millions' range
                        case 8:
                        case 9:
                            pos = (numDigits % 7) + 1;
                            place = " Million ";
                            break;
                        case 10://Billions's range
                            pos = (numDigits % 10) + 1;
                            place = " Billion ";
                            break;
                        //add extra case options for anything above Billion...
                        default:
                            isDone = true;
                            break;
                    }
                    if (!isDone)
                    {//if transalation is not done, continue...(Recursion comes in now!!)
                        word = translateWholeNumber(number.Substring(0, pos)) + place + translateWholeNumber(number.Substring(pos));
                        //check for trailing zeros
                        if (beginsZero) word = " and " + word.Trim();
                    }
                    //ignore digit grouping names
                    if (word.Trim().Equals(place.Trim())) word = "";
                }
            }
                catch
                {
                    ;
                }
            return word.Trim();
        }

        private String tens(String digit)
        {
            int digt = Convert.ToInt32(digit);
            String name = null;
            switch (digt)
            {
                case 10:
                    name = "Ten";
                    break;
                case 11:
                    name = "Eleven";
                    break;
                case 12:
                    name = "Twelve";
                    break;
                case 13:
                    name = "Thirteen";
                    break;
                case 14:
                    name = "Fourteen";
                    break;
                case 15:
                    name = "Fifteen";
                    break;
                case 16:
                    name = "Sixteen";
                    break;
                case 17:
                    name = "Seventeen";
                    break;
                case 18:
                    name = "Eighteen";
                    break;
                case 19:
                    name = "Nineteen";
                    break;
                case 20:
                    name = "Twenty";
                    break;
                case 30:
                    name = "Thirty";
                    break;
                case 40:
                    name = "Fourty";
                    break;
                case 50:
                    name = "Fifty";
                    break;
                case 60:
                    name = "Sixty";
                    break;
                case 70:
                    name = "Seventy";
                    break;
                case 80:
                    name = "Eighty";
                    break;
                case 90:
                    name = "Ninety";
                    break;
                default:
                    if (digt > 0)
                    {
                        name = tens(digit.Substring(0, 1) + "0") + " " + ones(digit.Substring(1));
                    }
                    break;
            }
            return name;
        }

        private String ones(String digit)
        {
            int digt = Convert.ToInt32(digit);
            String name = "";
            switch (digt)
            {
                case 1:
                    name = "One";
                    break;
                case 2:
                    name = "Two";
                    break;
                case 3:
                    name = "Three";
                    break;
                case 4:
                    name = "Four";
                    break;
                case 5:
                    name = "Five";
                    break;
                case 6:
                    name = "Six";
                    break;
                case 7:
                    name = "Seven";
                    break;
                case 8:
                    name = "Eight";
                    break;
                case 9:
                    name = "Nine";
                    break;
            }
            return name;
        }
    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        TextBox2.Text=changeToWords(TextBox1.Text);
    }
back to top