Wednesday, 31 July 2013

Encrypt and Decrypt with and without key

Today we'll see how to Encrypt and Decrypt with and without key in asp.net

Step 1 :Add class file in app code folder


Step 2: We are going to use Cryptography  so add in class file,

using System.Security.Cryptography;

using System.Text;



    public static string Key
    {
        set
        {
            _key = value;
        }
    }

    /// <summary>
    /// Encrypt the given string using the default key.
    /// </summary>
    /// <param name="strToEncrypt">The string to be encrypted.</param>
    /// <returns>The encrypted string.</returns>
    public static string Encrypt(string strToEncrypt)
    {
        try
        {
            return Encrypt(strToEncrypt, _key);
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }

    }

    /// <summary>
    /// Decrypt the given string using the default key.
    /// </summary>
    /// <param name="strEncrypted">The string to be decrypted.</param>
    /// <returns>The decrypted string.</returns>
    public static string Decrypt(string strEncrypted)
    {
        try
        {
            return Decrypt(strEncrypted, _key);
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }
    }

    /// <summary>
    /// Encrypt the given string using the specified key.
    /// </summary>
    /// <param name="strToEncrypt">The string to be encrypted.</param>
    /// <param name="strKey">The encryption key.</param>
    /// <returns>The encrypted string.</returns>
    public static string Encrypt(string strToEncrypt, string strKey)
    {
        try
        {
            TripleDESCryptoServiceProvider objDESCrypto = new     TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider objHashMD5 = new MD5CryptoServiceProvider();

            byte[] byteHash, byteBuff;
            string strTempKey = strKey;

            byteHash = objHashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(strTempKey));
            objHashMD5 = null;
            objDESCrypto.Key = byteHash;
            objDESCrypto.Mode = CipherMode.ECB; //CBC, CFB

            byteBuff = ASCIIEncoding.ASCII.GetBytes(strToEncrypt);
            return Convert.ToBase64String(objDESCrypto.CreateEncryptor().TransformFinalBlock(byteBuff, 0, byteBuff.Length));
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }
    }


    
    /// Decrypt the given string using the specified key.
   
    /// <param name="strEncrypted">The string to be decrypted.</param>
    /// <param name="strKey">The decryption key.</param>
    /// <returns>The decrypted string.</returns>
    public static string Decrypt(string strEncrypted, string strKey)
    {
        try
        {
            TripleDESCryptoServiceProvider objDESCrypto = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider objHashMD5 = new MD5CryptoServiceProvider();

            byte[] byteHash ;
            byte[] byteBuff ;
            string strTempKey = strKey;

            byteHash = objHashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(strTempKey));
            objHashMD5 = null;
            objDESCrypto.Key = byteHash;
            objDESCrypto.Mode = CipherMode.ECB; //CBC, CFB

            byteBuff = Convert.FromBase64String(strEncrypted);
            string strDecrypted = ASCIIEncoding.ASCII.GetString(objDESCrypto.CreateDecryptor().TransformFinalBlock(byteBuff, 0, byteBuff.Length));
            objDESCrypto = null;

            return strDecrypted;
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }
    }

}

3 step: Add default.aspx

<div>
    
        <asp:CheckBox ID="chkIsCustomKey" runat="server" 
            oncheckedchanged="chkIsCustomKey_CheckedChanged" Text="Use my custom key" 
            AutoPostBack="True" />
        <br />
        <br />
        <br />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Custom Key"></asp:Label>
&nbsp;&nbsp;<asp:TextBox ID="txtCustomKey" runat="server" Height="18px" Width="279px"></asp:TextBox>
        <br />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Input text"></asp:Label>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:TextBox ID="txtInputText" runat="server" Height="61px" Width="279px"></asp:TextBox>
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <asp:Label ID="Label3" runat="server" Text="OutPut Text"></asp:Label>
&nbsp;&nbsp;
        <asp:TextBox ID="txtOutputText" runat="server" Height="76px" Width="276px" ReadOnly="True"></asp:TextBox>
        <br />
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            Text="Encrypt" />
&nbsp;&nbsp;&nbsp;
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" 
            Text="Decrypt" />
        &nbsp;&nbsp;
        <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Clear" />
        <br />
        <br />
    

    </div>

step 4: In default.aspx.cs

 ON Page_Load()
    {
        txtCustomKey.Enabled = false;
    }
  private string SetKey()
        {
            if (chkIsCustomKey.Checked)
            {
                if (txtCustomKey.Text != String.Empty)
                {
                    return txtCustomKey.Text;
                }
                else
                {
                    return "SampleKey";
                }
            }
            else
            {
                return "SampleKey";
            }
        }
     btnEncrypt_Click()
      {
          txtOutputText.Text = Class1.Encrypt(txtInputText.Text, SetKey());
            
      }
     btnDecrypt_Click()
      {

          txtOutputText.Text = Class1.Decrypt(txtInputText.Text, SetKey());
       
      }
   btnClear_Click()
      {
          chkIsCustomKey.Checked = false;
          txtCustomKey.Text = String.Empty;
          txtCustomKey.Enabled = false;
          txtInputText.Text = String.Empty;
          txtOutputText.Text = String.Empty;
      }


     chkIsCustomKey_CheckedChanged()
      {
          if (chkIsCustomKey.Checked)
          {
              txtCustomKey.Enabled = true;
          }
          else
          {
              txtCustomKey.Enabled = false;
              txtCustomKey.Text = string.Empty;
          }

      }

OUTPUT:



Monday, 29 July 2013

Ajax CascadingDropDown using webservice

Ajax CascadingDropDown




Today will see how to use Ajax Cascading DropDown in asp.net

1 step: Add ajaxcontol tool kit in your visual studio toolbox  .Here my scenario is, there will be three drop down CATEGORY,SUBCATEGORY,PRODUCT .

FOR this we have three tables in database

2 step: Drag n Drop Three asp DropDownList and ajax CascadingDropDown and SCRIPTMANAGER.

  

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager>
   
   <div>

          ProductCategory

        <asp:DropDownList  ID="DDlcategory" runat="server">
        </asp:DropDownList>

  <asp:CascadingDropDown ID="CascadingDropDown1" TargetControlID="DDlcategory" Category="ProductCategory"   PromptText="Select ProductCategory" LoadingText="Loading ProductCategory.." ServiceMethod="BindCategoryDetails" ServicePath="~/CascadingDropdown.asmx"  runat="server">
          </asp:CascadingDropDown>

          <br />
          <br />
          ProductSubCategory&nbsp;&nbsp;&nbsp; 
         <asp:DropDownList  ID="DDlsubcategory" runat="server">
         </asp:DropDownList>
          <br />
          <br />
          Product&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp

          <asp:CascadingDropDown ID="CascadingDropDown2" TargetControlID="DDlsubcategory"  Category="Productsubcategory" ParentControlID="DDlcategory"  PromptText="Select Productsubcategory" LoadingText="Loading subcategory.." ServiceMethod="BindProductSubCategory" ServicePath="~/CascadingDropdown.asmx"  runat="server">
          </asp:CascadingDropDown>

        <asp:DropDownList ID="DDlproduct" runat="server">
        </asp:DropDownList>

        <asp:CascadingDropDown ID="CascadingDropDown3" TargetControlID="DDlproduct"  Category="Product" ParentControlID="DDlsubcategory"  PromptText="Select Product" LoadingText="Loading product.." ServiceMethod="BindProduct" ServicePath="~/CascadingDropdown.asmx"  runat="server">
          </asp:CascadingDropDown>

    </div>


3 step : Now add webservices in .cs file
             here we have to write 3 web method in web services. Please note you can change method    name reset of all will be same.

1) for Category

  [WebMethod]
 public CascadingDropDownNameValue[] BindCategoryDetails(string knownCategoryValues, string category)
    {

        
        SqlDataAdapter daCat = new SqlDataAdapter("select * from Tbl_ProductCategory", con);
        DataSet dsCat = new DataSet();
        daCat.Fill(dsCat);
    
        //create list and add items in it by looping through dataset table
        List<CascadingDropDownNameValue> catdetails = new List<CascadingDropDownNameValue>();
        foreach (DataRow dtrow in dsCat.Tables[0].Rows)
        {
            string ProdCategoryID = dtrow["ProdCategoryID"].ToString();
            string ProductCategoryName = dtrow["ProductCategoryName"].ToString();
            catdetails.Add(new CascadingDropDownNameValue(ProductCategoryName,ProdCategoryID));
        }
        return catdetails.ToArray();
    }

2) for subcategory
 [WebMethod]
    public CascadingDropDownNameValue[] BindProductSubCategory(string knownCategoryValues, string category)
    {
        int ProdCategoryID;
        //This method will return a StringDictionary containing the name/value pairs of the currently selected values
        StringDictionary ProdCategory = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        ProdCategoryID = Convert.ToInt32(ProdCategory["ProductCategory"]);
        con.Open();
        SqlCommand cmdProdCat = new SqlCommand("select * from Tbl_ProductSubCategory where ProdCategoryID=@ProdCategoryID", con);
        cmdProdCat.Parameters.AddWithValue("@ProdCategoryID", ProdCategoryID);
        cmdProdCat.ExecuteNonQuery();
        SqlDataAdapter daProdCategory = new SqlDataAdapter(cmdProdCat);
        DataSet dsProdCat = new DataSet();
        daProdCategory.Fill(dsProdCat);
        con.Close();
        //create list and add items in it by looping through dataset table
        List<CascadingDropDownNameValue> SubCategorydetails = new List<CascadingDropDownNameValue>();
        foreach (DataRow dtrow in dsProdCat.Tables[0].Rows)
        {
            string ProdSubCategoryID = dtrow["ProdSubCategoryID"].ToString();
            string ProductSubCategoryName = dtrow["ProductSubCategoryName"].ToString();
            SubCategorydetails.Add(new CascadingDropDownNameValue(ProductSubCategoryName, ProdSubCategoryID));
        }
        return SubCategorydetails.ToArray();

    }
3) for product

 [WebMethod]
    public CascadingDropDownNameValue[] BindProduct(string knownCategoryValues, string category)
    {
        int ProductID;
        //This method will return a StringDictionary containing the name/value pairs of the currently selected values
        StringDictionary Product = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        ProductID = Convert.ToInt32(Product["Productsubcategory"]);
        con.Open();
        SqlCommand cmdProduct = new SqlCommand("select * from tblProduct where ProdSubCategoryID=@ProdSubCategoryID", con);
        cmdProduct.Parameters.AddWithValue("@ProdSubCategoryID", ProductID);
        cmdProduct.ExecuteNonQuery();
        SqlDataAdapter daProduct = new SqlDataAdapter(cmdProduct);
        DataSet dsProduct = new DataSet();
        daProduct.Fill(dsProduct);
        con.Close();
        //create list and add items in it by looping through dataset table
        List<CascadingDropDownNameValue> Productdetails = new List<CascadingDropDownNameValue>();
        foreach (DataRow dtrow in dsProduct.Tables[0].Rows)
        {
            string ProductId = dtrow["ProductId"].ToString();
            string ProductName = dtrow["ProductName"].ToString();
            Productdetails.Add(new CascadingDropDownNameValue(ProductName, ProductId));
        }
        return Productdetails.ToArray();
    }

Saturday, 27 July 2013

J query Accordion using nested repeater control


               Follow Me To get Health tip's and bodybuilding
instagram:sayyedtanveer1410



J query Accordion using nested repeater control in asp.net



    OUT PUT

Step 1: Create database 



Second Step: Open visual studio add default.aspx page

IN HEAD TAG:

<style type="text/css">
     .topnav
        {
            width: 213px;
            padding: 40px 28px 25px 0;
            font-family: "CenturyGothicRegular" , "Century Gothic" , Arial, Helvetica, sans-serif;
        }
        
        ul.topnav
        {
            padding: 0;
            margin: 0;
            font-size: 1em;
            line-height: 0.5em;
            list-style: none;
        }
        
        ul.topnav li
        {
        }
        
        ul.topnav li a
        {
            line-height: 10px;
            font-size: 11px;
            padding: 10px 5px;
            color: Aqua;
            display: block;
            text-decoration: none;
            font-weight: bolder;
        }
        
        ul.topnav li a:hover
        {
            background-color: #675C7C;
            color: white;
        }
        
        ul.topnav ul
        {
            margin: 0;
            padding: 0;
            display: none;
        }
        
        ul.topnav ul li
        {
            margin: 0;
            padding: 0;
            clear: both;
        }
        
        ul.topnav ul li a
        {
            padding-left: 20px;
            font-size: 11px;
            font-weight: normal;
            outline: 0;
        }
        
        ul.topnav ul li a:hover
        {
            
            background-color: #D3C99C;
            font-family:Lucida Sans;
            color: #675C7C;
        }
        
        ul.topnav ul ul li a
        {
            color:Yellow;
            font-weight:bold;
             font-family:Lucida Sans;
            
            padding-left: 40px;
        }
        
        ul.topnav ul ul li a:hover
        {
            background-color: #D3CEB8;
            color:Red;
        }
        
        ul.topnav span
        {
            float: right;
        }
    </style>
 <script type="text/javascript" src="Scripts/jquery-1.5.2.min.js"></script>
 <script type="text/javascript" src="Scripts/scriptbreaker-multiple-accordion-1.js">DownLoad</script>

    <script language="JavaScript" type="text/javascript">
        $(document).ready(function () {
            $("#div").accordion({
                accordion: false,
                speed: 500,
                closedSign: '[+]',
                openedSign: '[-]'
            });
            $('.topnav ul:first').show(); 
            

        });
    </script>

IN BODY TAG: HERE WE NEED TO ADD THREE REPEATER CONTROL AND HIDDEN FIELD .

 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <div id="div">
                <ul class="topnav">
                    <asp:Repeater ID="parentRepeater" runat="server">
                        <ItemTemplate>
                            <li id="liFirst" style="background-color:Gray;"><a href="#">
                                <%# DataBinder.Eval(Container.DataItem, "ProductCategoryName")%></a>
                                <asp:HiddenField ID="ItemID" Value='<%#Eval("ProdCategoryID")%>' runat="server" Visible="false" />
                                <!-- start child repeater -->
                                <div style="height: auto;">
                                    <p style="margin-left: -29px;">
                                        <ul>
                                            <asp:Repeater ID="childRepeater" runat="server">
                                                <ItemTemplate>
                                                    <li><a href="#">
                                                        <%# DataBinder.Eval(Container.DataItem, "ProductSubCategoryName")%></a>
                                                        <br>
                                                        <ul>
                                                            <asp:Repeater ID="nestchildRepeater" runat="server">
                                                                <ItemTemplate>
                                                                    <li>
                                                                        <asp:HiddenField ID="ChildID" Value='<%#Eval("ProdSubCategoryID")%>' runat="server"
                                                                            Visible="false" />
                                                                        <asp:LinkButton ID="lnkBtnProducts" Text='<%# DataBinder.Eval(Container.DataItem, "ProductName")%>'
                                                                            runat="server" />
                                                                    </li>
                                                                </ItemTemplate>
                                                            </asp:Repeater>
                                                        </ul>
                                                    </li>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </ul>
                                    </p>
                                </div>
                                <!-- end child repeater -->
                            </li>
                        </ItemTemplate>
                    </asp:Repeater>
                    <!-- end parent repeater -->
                </ul>
            </div>
        </ContentTemplate>

    </asp:UpdatePanel>

3 Step: In default.aspx.cs on PageLoad ()

if (!IsPostBack)
        {
            // MY CATEGORY TABLE
            SqlDataAdapter cmd1 = new SqlDataAdapter("select * from Tbl_ProductCategory", con);
            DataSet ds = new DataSet();
            cmd1.Fill(ds, "Tbl_ProductCategory");

            // MY SUB CATEGORY TABLE
            SqlDataAdapter cmd2 = new SqlDataAdapter("select * from Tbl_ProductSubCategory", con);
            cmd2.Fill(ds, "Tbl_ProductSubCategory");

            // MY PRODUCT TABLE
            SqlDataAdapter cmd3 = new SqlDataAdapter("select * from tblProduct", con);
            cmd3.Fill(ds, "tblProduct");

            // bind parentRepeater... means Category eg cake
            parentRepeater.DataSource = ds.Tables["Tbl_ProductCategory"];
            parentRepeater.DataBind();

            // Now Check In parentRepeater To bind Child Repeater ...means subcategory of that category eg cake -> celebration cake
            foreach (RepeaterItem Item in parentRepeater.Items)
            {
               
                HiddenField hidden = (HiddenField)parentRepeater.Items[Item.ItemIndex].FindControl("ItemID");
               
                DataView dv = new DataView(ds.Tables["Tbl_ProductSubCategory"]);
                dv.RowFilter = "ProdCategoryID= " + Convert.ToInt32(hidden.Value);

                Repeater nestedDataList = (Repeater)parentRepeater.Items[Item.ItemIndex].FindControl("childRepeater");
                nestedDataList.DataSource = dv;
                nestedDataList.DataBind();

                // Now Check In ChildRepeater To bind NestedRepeater ...means Product of that Subcategory eg cake -> celebration cake -> blackforest
               
                foreach (RepeaterItem NestItem in nestedDataList.Items)
                {

                    HiddenField Nesthidden = (HiddenField)nestedDataList.Items[Item.ItemIndex].FindControl("ChildID");
                    
                    DataView dvNest = new DataView(ds.Tables["tblProduct"]);
                    dvNest.RowFilter = "ProdSubCategoryID= " + Convert.ToInt32(hidden.Value);
                    
                    Repeater nestedProdDataList = (Repeater)nestedDataList.Items[NestItem.ItemIndex].FindControl("nestchildRepeater");
                    nestedProdDataList.DataSource = dvNest;
                    nestedProdDataList.DataBind();
                }

            }
            con.Close();

        }

Enjoy ....

Monday, 22 July 2013

Captcha in asp.net

Code to create captcha in asp.net 

1 .Add default.aspx Page name as Chaptcha.aspx. On page load

using System.Drawing;
using System.Drawing.Text;

using System.Drawing.Imaging;



        try
        {
            Bitmap objBMP = new System.Drawing.Bitmap(100, 40);

            Graphics objGraphics = System.Drawing.Graphics.FromImage(objBMP);
            objGraphics.Clear(Color.LightPink);

            objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;

            //' Configure font to use for text
            Font objFont = new Font("verdana", 14, FontStyle.Bold);

            string randomStr = "";

            Random random = new Random();
            int length = 2;
            for (int i = 0; i < length; i++)
            {
                randomStr += ((char)random.Next(97, 122)).ToString();
                randomStr += ((char)random.Next(65, 91)).ToString();
                randomStr += random.Next(2, 9);
            }
            Session.Add("randomStr", randomStr);
            //' Write out the text
            objGraphics.DrawString(randomStr, objFont, Brushes.DarkSlateBlue, 4, 4);
            //' Set the content type and return the image
            Response.ContentType = "image/GIF";
            objBMP.Save(Response.OutputStream, ImageFormat.Gif);
            objFont.Dispose();
            objGraphics.Dispose();
            objBMP.Dispose();


        }
        catch
        {

        }

    }

2. add default2.aspx 

Add in <body>

              <img id="Image1" runat="server" />
              
                <asp:Button ID="btnRefresh" runat="server" Text="Refresh" 
                        PostBackUrl="~/default2.aspx" onclick="btnRefresh_Click" />


3. default2.aspx.cs

on page load

            Image1.Src = "Chaptcha.aspx";

 protected void btnRefresh_Click(object sender, EventArgs e)
    {
        txtcode.Text = "";
        Image1.Src = "Chaptcha.aspx";
    }

SlideShowExtender

Ajax Control Toolkit Example:SlideShowExtender 


Today we will learn how to use Ajax SlideShowExtender  using webservice,jquery to show in popup.

1 step : Drag n drop Ajax SlideShowExtender ,Add asp image tag  in default.aspx page.





In <body> tag.
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">

    </asp:ToolkitScriptManager>

<table style="border:Solid 3px #D55500; width:400px; height:400px" cellpadding="0" cellspacing="0">

<tr>
<td valign="top" style="width:660; height:320;">
<asp:Image ID="imgslides" runat="server" />
</td>
</tr>

<tr>
<td align="center" class="style1">
<asp:Button ID="btnPrevious" runat="server" Text="Prev" CssClass="button" />
<asp:Button ID="btnPlay" runat="server" Text="Play" CssClass="button" 
        />
<asp:Button ID="btnNext" runat="server" Text="Next" CssClass="button" />
</td>
</tr>
</table>

<asp:SlideShowExtender ID="SlideShowExtender1" runat="server"  AutoPlay="true"  Loop="true" NextButtonID="btnNext" PreviousButtonID="btnPrevious" PlayButtonID="btnPlay" PlayButtonText="Play" StopButtonText="Stop"
TargetControlID="imgslides" SlideShowServicePath="~/Slideshow.asmx" SlideShowServiceMethod="GetSlides" >

    </asp:SlideShowExtender


2 step: Create webservice ->Right click on Solution  Explorer Add new item webservice you will find webservice.asmx file in root and .cs file in appcode folder open webservice.cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using AjaxControlToolkit;

    [WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
   [System.Web.Script.Services.ScriptService]
public class Slideshow : System.Web.Services.WebService {
  
    DataSet ds = new DataSet();
    string[] imagenames = { };
    AjaxControlToolkit.Slide[] photos;
    public Slideshow () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

 [WebMethod(EnableSession = true)]
    public AjaxControlToolkit.Slide[] GetSlides()
    {
       
        ds = objExbt.getimages();// get all images in dataset
        try
        {
            if (ds.Tables.Count > 0)
            {
                 photos = new AjaxControlToolkit.Slide[ds.Tables[0].Rows.Count];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    photos[i] = new AjaxControlToolkit.Slide(("images/" + ds.Tables[0].Rows[i]["imgpath"]).ToString().Replace("\\", "/"), "", "");

                }
                
            }
            return photos;

           

               
            }


         
          
          
        
        catch (Exception)
        {

            throw;
        }
        finally
        {
           
        }
        
        

    }





output:

3 step: To open SlideShowExtender in popup add default2.apx
<head> tag

Here I have use Colorbox Download.


    <link href="ColorBox/colorbox.css" rel="stylesheet" type="text/css" />
    <script src="ColorBox/jquery.colorbox.js" type="text/javascript"></script>
    <script>
        $(document).ready(function () {
           
            $(".example7").colorbox({ iframe: true, innerWidth: 700, innerHeight: 420 });
        });
    </script>


<body> tag
Create anchor tag to open default page in popup
 <a class='example7'  id="link" href="Default.aspx">     </a>                                                                       

enjoy....

HoverMenuExtender

Ajax Control Toolkit Example: Using HoverMenuExtender

First Step: Add latest Ajax Control Toolkit in your toolbox
Right click on toolbox tab and add new item.



Second Step:Drag an drop HoverMenuExtender and radiobuttonlist in your  body tag.

<head runat="server">    <title>Ajax Hover Menu Extender</title>    <style type="text/css">          .PanelCSS          {              visibility:hidden;              }      </style>  </head>

<div>  
        <h2 style="color:DeepPink; font-style:italic;">Ajax Control Toolkit Example: Using HoverMenuExtender</h2>  
        <hr width="550" align="left" color="Pink" />  
        <asp:ScriptManager   
            ID="ScriptManager1"  
            runat="server"  
            >  
        </asp:ScriptManager>  
        <asp:HoverMenuExtender   
            ID="HoverMenuExtender1"  
            runat="server"  
            TargetControlID="Label1"  
            PopupControlID="Panel1"  
            PopupPosition="Bottom"  
            >  
        </asp:HoverMenuExtender>  
        <br /><br />  
        <asp:Label   
            ID="Label1"  
            runat="server"  
            Text="Color changeable label."  
            Font-Size="XX-Large"  
            Font-Names="Comic Sans MS"  
            >  
        </asp:Label>  
        <asp:Panel   
            ID="Panel1"  
            runat="server"  
            Width="300"  
            BorderColor="Gray"  
            BorderWidth="1"  
            CssClass="PanelCSS"  
            >  
            <asp:RadioButtonList   
                ID="RadioButtonList1"  
                runat="server"  
                RepeatColumns="3"   
                OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"  
                AutoPostBack="true"  
                >  
                <asp:ListItem>Tan</asp:ListItem>  
                <asp:ListItem>Crimson</asp:ListItem>  
                <asp:ListItem>DarkBlue</asp:ListItem>  
                <asp:ListItem>SeaGreen</asp:ListItem>  
                <asp:ListItem>OrangeRed</asp:ListItem>  
                <asp:ListItem>Magenta</asp:ListItem>  
                <asp:ListItem>DeepPink</asp:ListItem>  
            </asp:RadioButtonList>  
        </asp:Panel>  
    </div>

3 step: In default.aspx.cs


 protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)

    {

        Label1.ForeColor =System.Drawing.Color.FromName(RadioButtonList1.SelectedItem.Text);
    }  

OUTPUT:

Happy coding..