Monday, December 23, 2013

Play YouTube Video In HTML.

Here I am Going to explain how can you play YouTube Video in HTML.
Just add below  Code in your HTML page. You Can Change the Height,Width according to your Requirement. And Change Src="http://www.youtube.com/embed/ldrmaA72PJg" to your YouTube Video URL.

<iframe width="400" height="400"
src="http://www.youtube.com/embed/ldrmaA72PJg">
</iframe> 

Explanation :

Just Copy and Paste the below code in your HTML page .

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Play YouTube Video In HTML</title>
</head>
<body>
<pre class="code"
        style="background-color: white; border: 6px solid rgb(234, 234, 234); color: #444444; font-family: 'courier new'; font-size: 13px; line-height: 18px; outline: rgb(212, 212, 212) solid 1px; overflow: auto; padding: 15px; position: relative; text-align: center; width: 510px;"><img
        alt="" src="dotnetlogo.png" style="height: 64px; width: 230px" />
Play YouTube Video In HTML .

<iframe width="420" height="345"
src="http://www.youtube.com/embed/ldrmaA72PJg" id="I1" name="I1"></iframe>
WebSite : <a href="http://sarojasp.blogspot.in/">http://sarojasp.blogspot.in/</a>

</pre>
</body>
</html>


















If this Post Help You then Please Share.


Friday, December 20, 2013

Send Voice Mail using Notepad.

Here I am going to explain ,how can you send voice mail using Notepad.
Very easy way to send this mail.

Step : 1   -  Just copy and Paste the code in NotePad

  Dim message, saroj
message=("WelCome to Sarojasp.blogspot.com,I am very Happy to visit my site")
set saroj=CreateObject("sapi.spvoice")
saroj.Speak message

Step: 2 - Now save the file namely message.vbs  and close the notepad .

Step: 3 -Now Run and see the magic.

Step: 4 - Now  Create ZIp file (.rar) and Send Mail message to your Friends.


Wednesday, December 11, 2013

Count Remaining Characters in TextBox Using JavaScript.

Today I am going to explain How can you Count Remaining Characters in TextBox Using JavaScript.
Basically this program is use for sending SMS.
Demo : 

Now Copy the Code and Paste in .aspx Page

Monday, December 9, 2013

SQL Server Database BackUp using C# Code.

Here I am going to explain how to take the SQL Server database backup using C# coding.

 You have to add the following references in your application
Go to Your Application and Right Click on References folder and select Add Reference.
Now Go to "Browse" Tab and browse the following path-
"C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies"
Now Select the following dlls :
Demo :
  1. Microsoft.SqlServer.ConnectionInfo
  2. Microsoft.SqlServer.Management.Sdk.Sfc
  3. Microsoft.SqlServer.Smo
  4. Microsoft.SqlServer.SmoExtended
  5. Microsoft.SqlServer.SqlEnum  

Friday, November 29, 2013

Age Calculator Using JavaScript.

Copy and Paste the Code in .aspx Page :


Convert English Language to Other Language Using Google API.

Just Copy and Paste the Code in .aspx Page :
Change HINDI language to other as per your requirement.
Note : Write the Language Name in Capital letter.  



How to Disable Cut, Copy and Paste in Text Box using JavaScript.

Just Copy and Paste the Code in .aspx page :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tans.aspx.cs" Inherits="tans" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title> Disable Cut, Copy and Paste in Text Box using JavaScript</title>

<script type="text/javascript">
    $(document).ready(function() {
    $('#TextBox2').bind('cut copy paste', function(e) {
            e.preventDefault(); //disable cut,copy,paste
        });
    });
</script>
</head>
<body>
    <form id="form1" runat="server">
   <div>
   <asp:TextBox ID="TextBox2" runat="server" oncut="return false;" oncopy="return false;" onpaste="return false;"></asp:TextBox>

</div>
</form>
</body>

</html>


If you enjoy this post then please share.

Thursday, November 28, 2013

SQL Query for Find Highest Salary of a Employee.

Solution :

For  Highest Salary :

Select MAX(Salary) From EmployeeTable;

For 2Nd Highest Salary :

SELECT MAX(Salary) FROM EmployeeTable
WHERE Salary NOT IN (SELECT MAX(Salary) FROM EmployeeTable )

Find the nth highest salary using the TOP keyword in SQL Server :  

SELECT TOP 1 Salary
FROM (
      SELECT DISTINCT TOP N Salary
      FROM EmployeeTable
      ORDER BY Salary DESC
      ) AS Emp
ORDER BY Salary

Monday, November 25, 2013

Block Special Characters in JavaScript.

Copy and paste in <Head> section.

<script language="javascript" type="text/javascript">
        function DisableSplChars(e) {
            var keynum
            var keychar
            var numcheck
            // For Internet Explorer
            if (window.event) {
                keynum = e.keyCode
            }
            // For Netscape/Firefox/Opera
            else if (e.which) {
                keynum = e.which
            }
            keychar = String.fromCharCode(keynum)
            //List of special characters you want to restrict
            if (keychar == "!" || keychar == "@" || keychar == "#"
    || keychar == "$" || keychar == "%" || keychar == "^" || keychar == "&"
    || keychar == "*" || keychar == "(" || keychar == ")"
    || keychar == "<" || keychar == ">") {
                return false;
            }
            else {
                return true;
            }
        }


        function ValidateName(control, e) {
            if (control.value.length == 0 || !control.value.match(/[^\s]/)) {
                alert("Empty string detected.");
                control.focus();


                if (window.event) {
                    window.event.returnValue = false;
                }
                else {
                    e.preventDefault();
                }
            }
        }
    </script>

and, add in TextBox onkeypress="javascript:return DisableSplChars(event);"

<asp:TextBox ID="TextBox1" runat="server" onkeypress="javascript:return DisableSplChars(event);"></asp:TextBox>

Friday, November 22, 2013

Generate Random number in Asp.Net

Just Copy and paste the Code.

public static string GenerateRandomNumber(int Length)
    {
        
            string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
            Random randNumber = new Random();
            char[] chars = new char[Length];
            int allowedCharCount = _allowedChars.Length;

            for (int i = 0; i <= Length - 1; i++)
            {
                chars[i] = _allowedChars[Convert.ToInt32((_allowedChars.Length) * randNumber.NextDouble())];
            }
            return new string(chars);
        
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        try
        {

            string num = GenerateRandomNumber(5);
            Label1.Text = num;
        }
        catch
        {
        }
    }

Click Here For Demo

How to encrypt password in Asp.Net using MD5.

Just Copy and Paste the Code in your .aspx page.

(.aspx Page)

<div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" 
            onclick="Button1_Click1" />
       
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        
    </div>

(.aspx.cs page)

 public string Md5AddSecret(string sPassword)
    {
        System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
        byte[] bs = System.Text.Encoding.UTF8.GetBytes(sPassword);
        bs = x.ComputeHash(bs);
        System.Text.StringBuilder s = new System.Text.StringBuilder();
        foreach (byte b in bs)
        {
            s.Append(b.ToString("x2").ToLower());
        }
        return s.ToString();
    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        Label1.Text = Md5AddSecret(TextBox1.Text);

    }

Click Here For Demo

Make Your Computer Speak ( Using Notepad).

1. Copy and Paste the Below Code in Notepad.
2. Save the file in Name Saroj.vbs  , and close notepad.
3. Run the file. 

Dim message, saroj
message=InputBox("Write In the Box what you Want?","Speak to Me")
set saroj=CreateObject("sapi.spvoice")
saroj.Speak message


Have a Nice day.


Snake game in Html.

Just Copy and Paste the Code in Your HTML Page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html>
<head>
<script type="text/javascript">

/****************************************************
*This game is available at http://www.sarojdotnet.somee.com
****************************************************/

Thursday, November 21, 2013

Always Running Marquee Text and Images Using JavaScript.

Copy and Paste the Code where you want to show the Marquee.


Show Welcome Message in your Page.

Just Copy and Paste in your page.

<body onload="position_at_top();expand()">

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

<div style="position:absolute;color:black" id="test"></div>

Flying Letters Using JavaScript

Just Copy and paste the Code in <Body> Section.

 <h2 id="fly" class="style1">Thanks for visiting  SarojAspDotnet...</h2>

<script type="text/javascript">
message = document.getElementById("fly").innerHTML; // $ = taking a new line
distance = 50; // pixel(s)
speed = 200; // milliseconds

var txt="",
 num=0,
 num4=0,
 flyofle="",
 flyofwi="",
 flyofto="",
 fly=document.getElementById("fly");

Show conformation Message Before Delete data using JavaScript .



Solution :

Just Add OnClientClick= "javascript:return confirm('Are you sure to delete this Data?');" in Button Control.
Copy and  paste  the Code in your Page.

      <asp:Button Text="Delete" runat="server" OnClick = "Submit" OnClientClick= "javascript:return confirm('Are you sure to delete this Data?');"/>