Friday 30 November 2012

Encrypted Stored Procedure in Sql Server 2008.


Encrypted stored procedure means no one can seen your create procedure statement. Encryption Convert original  sql server text of create procedure statement into a obfuscate formate. The output of obsfusacte formate is not visible by any of the catalog view in sql. User have no access to system table or database file .

This option is not valid for CLR stored procedure.

First Create a table ……..

Create table emp(empno int, empname varchar(50), empsal varchar(50));

Execute the code.

Now create procedure……

Create procedure sp_empDetails
With encryption
As
Select * from emp;

Execute the stored procedure

exec sp_helptext sp_empDetails

When you execute with above code (means using with sp_helptext) this will give a text message see figure below..

Please add your valuable comment. You can also add constructive information because it will improve the post infromation. 

Thursday 29 November 2012

Image Zoom In and Zoom Out using JavaScript in Asp.net.


In the previous I had explained ’ Image Zoom In and Zoom outusing Jquery in Asp.Net’. In this post I have explaind  ‘Image Zoom In and Zoom out using Simple JavaScript  code in Asp.Net’.

Code For Design Page:-

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Image Zoom In and Zoom Out using JavaScript</title>
    <script language="javascript" type="text/javascript">
        var nw, nh, oh, ow;
        function zoomImage(IWideSamll, IHighSamll, IWideLarge, IHighLarge, whichImage) {
            ow = whichImage.style.width;
            oh = whichImage.style.height;
            if ((ow == IWideLarge) || (oh == IHighLarge)) {
                nw = IWideSamll;
                nh = IHighSamll;
            }
            else {
                nw = IWideLarge;
                nh = IHighLarge;
            }
            whichImage.style.width = nw;
            whichImage.style.height = nh;
        }
    </script>
  
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <img alt="" src="1.jpg" width="100" height="100" onmouseover="zoomImage('400px','200px','400px','200px',this);" onmouseout="zoomImage('50px','70px','50px','70px',this)" />
        
    </div>
    </form>
</body>
</html>

Debug the code and run.

Wednesday 28 November 2012

Project Requirement.

If any body require a project , you can contact me at sushilct86@gmail.com .

AdRotator Example using Timer in Asp.net. Or AdRotator using Ajax In Asp.net.


In the previous I had explained ‘AdRotator Example in Asp.Net  using Xml  file’. In this post I am explaining ‘AdRotator using Ajax in Asp.Net’.
Just Do the same thing as previously AdRotator Example.
Follow the Code which is written below.

Design.aspx:-

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
     <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick"></asp:Timer>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/AdRotatorXMLFile.xml" />
        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger EventName="Tick" ControlID="Timer1" />
        </Triggers>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Design.aspx.cs:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

    }
    protected void Timer1_Tick(object sender, EventArgs e)
    {

    }
}

In this example Timer is used because it displays the Advertisement at short interval of time automatically.
Debug code and run.

Tuesday 27 November 2012

How to use stored procedure in SqlDataSourceID in GridView in Asp.Net .


In this post  I am describing ‘ how to use stored procedure in SqlDataSourceID in Asp.Net’. It is very simple. Please follow the step which is given below.
Step1: Open Visual studio
·         Create new website
·         Give it name
·         Click ok.
Step2:- You have to add new page
·         Right click on project solution
·         Select Add new items
·         Give it a name
·         Click ok
Step3: Right a stored procedure in sqlServer
Note: One column must be primary key in the table. Procedure given below  in which EmployeeID is primary key in the table.

CREATE PROCEDURE [dbo].[sp_employee]
(
@EmployeeID int
)
AS
BEGIN
     
      select * from Employee where EmployeeID=@EmployeeID;
END


Step4: Drag and drop a GridView on the page

Step5: Click on gridView  -> choose data source .

Choose stored procedure instead of  table . See the figure.



After that choose the stored procedure instead of sql table.

Select your stored procedure .

Give the Default value (means in your table there must be one column is primary key )

Click  next and then click finish button.

Step6: Design page source code

Default.aspx:

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataKeyNames="EmployeeID" DataSourceID="SqlDataSource1">
            <Columns>
                <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID"
                    InsertVisible="False" ReadOnly="True" SortExpression="EmployeeID" />
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
                <asp:BoundField DataField="BirthDate" HeaderText="BirthDate"
                    SortExpression="BirthDate" />
                <asp:BoundField DataField="MaritalStatus" HeaderText="MaritalStatus"
                    SortExpression="MaritalStatus" />
                <asp:BoundField DataField="Gender" HeaderText="Gender"
                    SortExpression="Gender" />
                <asp:BoundField DataField="HireDate" HeaderText="HireDate"
                    SortExpression="HireDate" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:modiConnectionString %>"
            SelectCommand="sp_employee" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="EmployeeID" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

Debug the code and run.

Monday 26 November 2012

How to check given no is even or odd in c#.


Here i am explaining simple c# program to check even or odd no.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EvenOrOdd
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Check the Enter No is even or odd");
            Console.Write("Enter the no:");
            int n = Convert.ToInt32(Console.ReadLine());
            if(n<0)
            {
                Console.Write("You have enter negative no. Sorry...");
            }

            else if (n % 2 == 0)
            {
                Console.Write("Entered no is even.");
            }
            else
            {
                Console.Write("Entered no is odd.");
            }
            Console.ReadKey();
        }
    }
}

debug the code and run. 

Sunday 25 November 2012

Image Zoom in and zoom out in Asp.Net using Jquery on mouseover and mouseout.


This post describe how to create simple image zoom in and zoom out effect with jQuery and css by step by step.
Step1: First you have to create a web application in visual studio.
i>Go to visual studio
ii>open a new web project
iii> Give it name whatever you want
iv> Click ok
Step2:  second you  have to add new page in the project
i> Go to the solution explorer
ii> Right click on the project name
iii> select Add new items and give it a name
iv> click ok
Step3: Add some image in “image ” folder of the project
Step4: Add css code inside the header section. Below code is given
<style type="text/css">
    #image
    {
        width:100%;
        overflow:hidden;
    }
    #image a
    {
        position:relative;
        float:left;
        margin:5px;
    }
    #image a span
    {
        background-repeat:no-repeat;
        width:48px;
        height:48px;
        position:absolute;
        left:15px;
        right:15px;
    }
    #image
    {
        border:solid 1px #999;
        padding:5px;
    }
   
    </style>

Step5: Add JQuery code . If you are using Visual studio 2010 then it already have jQuery file when you are creating new web site. If you are using 2008 then you have to download Jquery File.See the figure..

Step6: Write the given code inside the header section.
<script src="Scripts/jquery-1.4.1.min.js" type="text/jscript"></script>
Step7:  add javaScript code in the header section which is given below
<script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#image').width(200);
            $('#image').mouseover(function () {
                $(this).css("cursor", "pointer");
                $(this).animate({ width: "500px" }, 'slow');
            });
            $('#image').mouseout(function () {
                $(this).css("cursor", "pointer");
                $(this).animate({ width: "200px" }, 'slow');
            });
        });
    </script>
Step8:  Design page
Deafult.aspx:-
<body>
    <form id="form1" runat="server">
    <div>
    <h1>Image Zoom </h1><br />
    <a>
        <asp:Image ID="image" runat="server" ImageUrl="~/image/1.jpg" />
        </a>
    </div>
    </form>
</body>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Image Zoom</title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/jscript"></script>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#image').width(200);
            $('#image').mouseover(function () {
                $(this).css("cursor", "pointer");
                $(this).animate({ width: "500px" }, 'slow');
            });
            $('#image').mouseout(function () {
                $(this).css("cursor", "pointer");
                $(this).animate({ width: "200px" }, 'slow');
            });
        });
    </script>
    <style type="text/css">
    #image
    {
        width:100%;
        overflow:hidden;
    }
    #image a
    {
        position:relative;
        float:left;
        margin:5px;
    }
    #image a span
    {
        background-repeat:no-repeat;
        width:48px;
        height:48px;
        position:absolute;
        left:15px;
        right:15px;
    }
    #image
    {
        border:solid 1px #999;
        padding:5px;
    }
   
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>Image Zoom </h1><br />
    <a>
        <asp:Image ID="image" runat="server" ImageUrl="~/image/1.jpg" />
        </a>
    </div>
    </form>
</body>
</html>

Run the code and see the output.

Saturday 24 November 2012

Ajax WaterMarkControl code in Asp.net.


Hi Friends , Here I have Written a code for Ajax WaterMark Control code in Asp.Net.

WaterMark.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WaterMarkControl.aspx.cs" Inherits="Ajax_WaterMarkControl" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><asp:textbox ID="Textbox1" runat="server"></asp:textbox>
        <asp:TextBoxWatermarkExtender ID="Textbox1_TextBoxWatermarkExtender"
            runat="server" Enabled="True" TargetControlID="Textbox1"
            WatermarkText="UserName.......">
        </asp:TextBoxWatermarkExtender>
    </div>
    </form>
</body>
</html>

Run this code and see the out. When you click a mouse on textbox then text showing is invisible. If you will not write anything in this text and click anywhere on the page hidden text will again appear. This is more simple than JavaScript code.