Repeater in asp.net | use of repeater control


A repeater in asp.net: In this tutorial, I am going to discuss about the repeater control in asp.net c#, we will also discuss about crud operation with "repeater control" in asp.net.

Why "Repeater in asp.net" 
In Repeater control, the Data records to be displayed depends upon the Templates specified and the only HTML generated is the due to the Templates.


Repeater in asp.net,repeater control
Repeater in asp.net 

The actual use of  repeater control is to display a list of data from the sql server ,we can also use many more data source to display the record on repeater in asp.net.

Here are the some list of templates which is used with repeater control 

1.Item Template
2.Header Template
3.Footer Template
4.Separator Template
5.Alternating Item Template 

#Step 1: Now, I am going to show you how you can implement repeater control in asp.net .  First, you have to create a table to store data of  repeater control

create database Repeater_control
use Repeater_control

create table repeaterinaspnet
(
pid int identity primary key,
Name varchar(50),
Price varchar(50),
Pic varchar(50)
)



create proc usp_product_get
as
 begin
select * from repeaterinaspnet
end

create proc sp_product_insert
@Name varchar(50),
@Price varchar(50),
@Pic varchar(50)
as
 begin
insert into repeaterinaspnet(Name,Price,Pic)values(@Name,@Price,@Pic)
end

create proc usp_product_delete
@pid int,
@pic varchar(1000) output
as
 begin
  select @pic=pic from repeaterinaspnet
delete from  repeaterinaspnet where pid=@pid
end

ALTER proc sp_product_update
@pid int,
@Name varchar(50),
@Price varchar(50),
@Pic varchar(50)
as
 begin
  update repeaterinaspnet set Name=@Name,Price=@Price, @Pic=pic where pid=@pid

end

#Step 2: Now add a connection in web..config file

<configuration>
<connectionStrings>
  <add connectionString ="data source=SANJAY\SQL2012; initial catalog=DBUPLOAD; integrated security=true;" name ="reapterconnection"/>
</connectionStrings>
    <system.web>
      <compilation debug="true" targetFramework="4.5.2" />
      <httpRuntime targetFramework="4.5.2" />
    </system.web>

</configuration>

#Step 3: Add a asp.net c# webform , in my case my webform name is repeater_control _in_aspnet.aspx.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="repeater_in_aspnet.aspx.cs" Inherits="repeater_in_aspnet" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <table>
                <tr>
                    <td>Name :</td>
                    <td>
                        <asp:TextBox ID="txt_name" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Price :</td>
                    <td>
                        <asp:TextBox ID="txt_price" runat="server"></asp:TextBox></td>
                </tr>
                <tr>
                    <td>Pic :</td>
                    <td>
                        <asp:FileUpload ID="fupic" runat="server"></asp:FileUpload></td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <asp:Button ID="btn_save" runat="server" Text="Save" OnClick="btn_save_Click" /></td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <asp:Repeater ID="RepDetails" runat="server" OnItemCommand="RepDetails_ItemCommand">
                            <HeaderTemplate>
                                <table style="border: 1px solid #df5015; width: 500px" cellpadding="0">
                                    <tr style="background-color: #df5015; color: White">
                                        <td>
                                            <b>Name</b>
                                        </td>
                                        <td>
                                            <b>Price</b>
                                        </td>
                                        <td>
                                            <b>Pic</b>
                                        </td>
                                        <td></td>
                                        <td></td>
                                    </tr>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr style="background-color: #EBEFF0">
                                    <td>
                                        <%#Eval("Name"%>
                                    </td>
                                    <td>
                                        <%#Eval("Price"%>
                                    </td>
                                    <td>
                                        <asp:Image ID="Image1" runat="server" Width="70px" Height="50px" ImageUrl='<%#Eval("Pic","~/repeaterdata/{0}"%>' />
                                    </td>
                                    <td>
                                        <asp:LinkButton ID="lnkbtnedit" runat="server" Text="Edit" CommandArgument='<%#Eval("PID"%>' CommandName="EDT"></asp:LinkButton>
                                    </td>
                                    <td>
                                        <asp:LinkButton ID="lnkbtndelete" runat="server" Text="Delete" CommandArgument='<%#Eval("PID"%>' CommandName="DLT"></asp:LinkButton>
                                    </td>
                                </tr>
                            </ItemTemplate>
                            <FooterTemplate>
                                </table>
                            </FooterTemplate>
                        </asp:Repeater>

                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>


#Step 4: Come to the repeater_control _in_aspnet.aspx.cs page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Web.UI.HtmlControls;

public partial class repeater_in_aspnet : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["reapterconnection"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Fill_Reapter();
        }
    }
    //Bind the repeater control
    public void Fill_Reapter()
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("usp_product_get", con);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        if (ds.Tables[0].Rows.Count > 0)
        {
            RepDetails.DataSource = ds;
            RepDetails.DataBind();
        }
        else
        {
            RepDetails.DataSource = null;
            RepDetails.DataBind();
        }

        con.Close();
    }
     //Button to insert data in repeater control
    protected void btn_save_Click(object sender, EventArgs e)
    {
        string FN = "";
        if (btn_save.Text == "Save")
        {
            FN = DateTime.Now.Ticks.ToString() + Path.GetFileName(fupic.PostedFile.FileName);
            fupic.SaveAs(Server.MapPath("repeaterdata" + "\\" + FN));
            con.Open();
            SqlCommand cmd = new SqlCommand("sp_product_insert", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Name", txt_name.Text);
            cmd.Parameters.AddWithValue("@Price", txt_price.Text);
            cmd.Parameters.AddWithValue("@Pic", FN);
            cmd.ExecuteNonQuery();
            con.Close();
        }
        else if (btn_save.Text == "Update")
        {
            FN = Path.GetFileName(fupic.PostedFile.FileName);
            con.Open();
            SqlCommand cmd = new SqlCommand("sp_product_update", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@pid", ViewState["PID"]);
            cmd.Parameters.AddWithValue("@Name", txt_name.Text);
            cmd.Parameters.AddWithValue("@Price", txt_price.Text);
            if (FN != "")
            {
                FN = DateTime.Now.Ticks.ToString() + Path.GetFileName(fupic.PostedFile.FileName);
                cmd.Parameters.AddWithValue("@Pic", FN);
                File.Delete(Server.MapPath("repeaterdata" + "\\" + ViewState["PIC"]));
                fupic.SaveAs(Server.MapPath("repeaterdata" + "\\" + FN));
            }
            else
            {
                cmd.Parameters.AddWithValue("@Pic", ViewState["PIC"]);
            }
            cmd.ExecuteNonQuery();
            con.Close();
        }
        Fill_Reapter();
    }

     //Edit and update event for the repeater control
    protected void RepDetails_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int PID = int.Parse(e.CommandArgument.ToString());
        if (e.CommandName == "EDT" && PID > 0)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("usp_product_get", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                DataView dv = new DataView(ds.Tables[0]);
                dv.RowFilter = "PID=" + PID;
                DataTable dt = new DataTable();
                dt = dv.ToTable();
                txt_name.Text = dt.Rows[0]["Name"].ToString();
                txt_price.Text = dt.Rows[0]["Price"].ToString();
                ViewState["PIC"] = dt.Rows[0]["Pic"].ToString();
                ViewState["PID"] = PID;
                btn_save.Text = "Update";
            }
        }
        else if (e.CommandName == "DLT" && PID > 0)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("usp_product_delete", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@pid", PID);
            SqlParameter param = cmd.Parameters.Add("@pic"SqlDbType.VarChar, 200);
            param.Direction = ParameterDirection.Output;
            cmd.ExecuteNonQuery();
            con.Close();
            string FF = cmd.Parameters["@pic"].Value.ToString();
            File.Delete(Server.MapPath("repeaterdata" + "\\" + FF));
            Fill_Reapter();
        }
    }
}




Read More

Jquery Toggle left to right animation asp.net, Implemetnt eaisly


Introduction
In this tutorial, I am going to show how you can implement "Jquery Toggle left to right animation". The process is very easy to implement.





<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
       <link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/base/jquery-ui.min.css" rel="stylesheet" type="text/css" />
    <script src="https://code.jquery.com/jquery-1.6.2.min.js" type="text/javascript"></script>
    <script src="https://code.jquery.com/ui/1.9.1/jquery-ui.min.js" type="text/javascript"></script>
    <link href="css/demos.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .toggler {
            width500px;
            height200px;
            positionrelative;
        }

        #button {
            padding.5em 1em;
            text-decorationnone;
        }

        #effect {
            width240px;
            height135px;
            padding0.4em;
            positionrelative;
            background#fff;
        }

            #effect h3 {
                margin0;
                padding0.4em;
                text-aligncenter;
            }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#button").toggle(
                     function () {
                         $("#effect").animate({
                             backgroundColor: "#aa0000",
                             color: "#fff",
                             width: 500
                         }, 1000);
                     },
                     function () {
                         $("#effect").animate({
                             backgroundColor: "#fff",
                             color: "#000",
                             width: 240
                         }, 1000);
                     }
              );
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="demo">
            <div class="toggler">
                <div id="effect" class="ui-widget-content ui-corner-all">
                    <h3 class="ui-widget-header ui-corner-all">Animate</h3>
                    <p>
                        In this tutorial , I am going to discuss about the "jquery toggle left to right animation".
                    </p>
                    <p>
                        In this tutorial , I am going to discuss about the "jquery toggle left to right animation".
                    </p>
                    <p>
                        In this tutorial , I am going to discuss about the "jquery toggle left to right animation".
                    </p>
                </div>
            </div>
            <a href="#" id="button" class="ui-state-default ui-corner-all">Toggle Effect</a>
        </div>
        
    </form>
</body>

</html>


demo.css

body {
                font-size: 62.5%;
}

table {
                font-size: 1em;
}

/* Site
   -------------------------------- */

body {
                font-family: "Trebuchet MS", "Helvetica", "Arial",  "Verdana", "sans-serif";
}

/* Layout
   -------------------------------- */

.layout-grid {
                width: 960px;
}

.layout-grid td {
                vertical-align: top;
}

.layout-grid td.left-nav {
                width: 140px;
}

.layout-grid td.normal {
                border-left: 1px solid #eee;
                padding: 20px 24px;
                font-family: "Trebuchet MS", "Helvetica", "Arial",  "Verdana", "sans-serif";
}

.layout-grid td.demos {
                background: url('/images/demos_bg.jpg') no-repeat;
                height: 337px;
                overflow: hidden;
}

/* Normal
   -------------------------------- */

.normal h3,
.normal h4 {
                margin: 0;
                font-weight: normal;
}

.normal h3 {
                padding: 0 0 9px;
                font-size: 1.8em;
}

.normal h4 {
                padding-bottom: 21px;
                border-bottom: 1px dashed #999;
                font-size: 1.2em;
                font-weight: bold;
}

.normal p {
                font-size: 1.2em;
}

/* Demos */

.demos-nav, .demos-nav dt, .demos-nav dd, .demos-nav ul, .demos-nav li {
                margin: 0;
                padding: 0
}

.demos-nav {
                float: left;
                width: 170px;
                font-size: 1.3em;
}

.demos-nav dt,
.demos-nav h4 {
                margin: 0;
                padding: 0;
                font: normal 1.1em "Trebuchet MS", "Helvetica", "Arial",  "Verdana", "sans-serif";
                color: #e87b10;
}

.demos-nav dt,
.demos-nav h4 {
                margin-top: 1.5em;
                margin-bottom: 0;
                padding-left: 8px;
                padding-bottom:5px;
                line-height: 1.2em;
                border-bottom: 1px solid #F4F4F4;
}

.demos-nav dd a,
.demos-nav li a {
                border-bottom: 1px solid #F4F4F4;
                display:block;
                padding: 4px 3px 4px 8px;
                font-size: 90%;
                text-decoration: none;
                color: #555 ;
                margin:2px 0;
                height:13px;
}

.demos-nav dd a:hover,
.demos-nav dd a:focus,
.demos-nav dd a:hover,
.demos-nav dd a:focus {
                background: #f3f3f3;
                color:#000;
                -moz-border-radius: 5px; -webkit-border-radius: 5px;
}
 .demos-nav dd a.selected {
                background: #555;
                color:#ffffff;
                -moz-border-radius: 5px; -webkit-border-radius: 5px;
}


/* new styles for demo pages, added by Filament 12.29.08
eventually we should convert the font sizes to ems -- using px for now to minimize style conflicts
*/

.normal h3.demo-header { font-size:32px; padding:0 0 5px; border-bottom:1px solid #eee; text-transform: capitalize; }
.normal h4.demo-subheader { font-size:10px; text-transform: uppercase; color:#999; padding:8px 0 3px; border:0; margin:0; }
.normal a:link,
.normal a:visited { color:#1b75bb; text-decoration:none; }
.normal a:hover,
.normal a:active { color:#0b559b; }

#demo-config { padding:20px 0 0; }

#demo-frame { float:left; width:540px; height:380px; border:1px solid #ddd; overflow: auto; position: relative; }
#demo-frame h3, #demo-frame h4 { padding: 0; font-weight: bold; font-size: 1em; }

#demo-config-menu { float:right; width:180px;  }
#demo-config-menu h4 { font-size:13px; color:#666; font-weight:normal; border:0; padding-left:18px; }

#demo-config-menu ul { list-style: none; padding: 0; margin: 0; }

#demo-config-menu li { font-size:12px; padding:0 0 0 10px; margin:3px 0; zoom: 1; }

#demo-config-menu li a:link,
#demo-config-menu li a:visited { display:block; padding:1px 8px 4px; border-bottom:1px dotted #b3b3b3; }
* html #demo-config-menu li a:link,
* html #demo-config-menu li a:visited { padding:1px 8px 2px; }
#demo-config-menu li a:hover,
#demo-config-menu li a:active { background-color:#f6f6f6; }

#demo-config-menu li.demo-config-on { background: url(images/demo-config-on-tile.gif) repeat-x left center; }

#demo-config-menu li.demo-config-on a:link,
#demo-config-menu li.demo-config-on a:visited,
#demo-config-menu li.demo-config-on a:hover,
#demo-config-menu li.demo-config-on a:active { background: url(images/demo-config-on.gif) no-repeat left; padding-left:18px; color:#fff; border:0; margin-left:-10px; margin-top: 0px; margin-bottom: 0px; }

#demo-source, #demo-notes {
                clear: both;
                padding: 20px 0 0;
                font-size: 1.3em;
}

#demo-notes { width:520px; color:#333; font-size: 1em; }
#demo-notes p code, .demo-description p code { padding: 0; font-weight: bold; }
#demo-source pre, #demo-source code { padding: 0; }
code, pre { padding:8px 0 8px 20px ; font-size: 1.2em; line-height:130%;  }

#demo-source a:link,
#demo-source a:visited,
#demo-source a:hover,
#demo-source a:active { font-size:12px; padding-left:13px; background-position: left center; background-repeat: no-repeat; }

#demo-source a.source-open:link,
#demo-source a.source-open:visited,
#demo-source a.source-open:hover,
#demo-source a.source-open:active { background-image: url(images/demo-spindown-open.gif); }

#demo-source a.source-closed:link,
#demo-source a.source-closed:visited,
#demo-source a.source-closed:hover,
#demo-source a.source-closed:active { background-image: url(images/demo-spindown-closed.gif); }

div.demo {
                padding:12px;
                font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif";
}

div.demo h3.docs { clear:left; font-size:12px; font-weight:normal; padding:0 0 1em; margin:0; }

div.demo-description {
                clear:both;
                padding:12px;
                font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif";
                font-size: 1.3em;
                line-height: 1.4em;
}

.ui-draggable, .ui-droppable {
                background-position: top left;
}

.left-nav .demos-nav {
                padding-right: 10px;
}

#demo-link { font-size:11px;  padding-top: 6px; clear: both; overflow: hidden; }
#demo-link a span.ui-icon { float:left; margin-right:3px; }

/* Component containers
----------------------------------*/
#widget-docs .ui-widget { font-family: Trebuchet MS,Verdana,Arial,sans-serif; font-size: 1em; }
#widget-docs .ui-widget input, #widget-docs .ui-widget select, #widget-docs .ui-widget textarea, #widget-docs .ui-widget button { font-family: Trebuchet MS,Verdana,Arial,sans-serif; font-size: 1em; }
#widget-docs .ui-widget-header { border: 1px solid #ffffff; background: #464646 url(images/464646_40x100_textures_01_flat_100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; }
#widget-docs .ui-widget-header a { color: #ffffff; }
#widget-docs .ui-widget-content { border: 1px solid #ffffff; background: #ffffff url(images/ffffff_40x100_textures_01_flat_75.png) 50% 50% repeat-x; color: #222222; }
#widget-docs .ui-widget-content a { color: #222222; }

/* Interaction states
----------------------------------*/
#widget-docs .ui-state-default, #widget-docs .ui-widget-content #widget-docs .ui-state-default { border: 1px solid #666666; background: #555555 url(images/555555_40x100_textures_03_highlight_soft_75.png) 50% 50% repeat-x; font-weight: normal; color: #ffffff; outline: none; }
#widget-docs .ui-state-default a { color: #ffffff; text-decoration: none; outline: none; }
#widget-docs .ui-state-hover, #widget-docs .ui-widget-content #widget-docs .ui-state-hover, #widget-docs .ui-state-focus, #widget-docs .ui-widget-content #widget-docs .ui-state-focus { border: 1px solid #666666; background: #444444 url(images/444444_40x100_textures_03_highlight_soft_60.png) 50% 50% repeat-x; font-weight: normal; color: #ffffff; outline: none; }
#widget-docs .ui-state-hover a { color: #ffffff; text-decoration: none; outline: none; }
#widget-docs .ui-state-active, #widget-docs .ui-widget-content #widget-docs .ui-state-active { border: 1px solid #666666; background: #ffffff url(images/ffffff_40x100_textures_01_flat_65.png) 50% 50% repeat-x; font-weight: normal; color: #F6921E; outline: none; }
#widget-docs .ui-state-active a { color: #F6921E; outline: none; text-decoration: none; }

/* Interaction Cues
----------------------------------*/
#widget-docs .ui-state-highlight, #widget-docs .ui-widget-content #widget-docs .ui-state-highlight {border: 1px solid #fcefa1; background: #fbf9ee url(images/fbf9ee_40x100_textures_02_glass_55.png) 50% 50% repeat-x; color: #363636; }
#widget-docs .ui-state-error, #widget-docs .ui-widget-content #widget-docs .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/fef1ec_40x100_textures_05_inset_soft_95.png) 50% bottom repeat-x; color: #cd0a0a; }
#widget-docs .ui-state-error-text, #widget-docs .ui-widget-content #widget-docs .ui-state-error-text { color: #cd0a0a; }
#widget-docs .ui-state-disabled, #widget-docs .ui-widget-content #widget-docs .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
#widget-docs .ui-priority-primary, #widget-docs .ui-widget-content #widget-docs .ui-priority-primary { font-weight: bold; }
#widget-docs .ui-priority-secondary, #widget-docs .ui-widget-content #widget-docs .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }

/* Icons
----------------------------------*/

/* states and images */
#demo-frame-wrapper .ui-icon, #widget-docs .ui-icon { width: 16px; height: 16px; background-image: url(images/222222_256x240_icons_icons.png); }
#widget-docs .ui-widget-content .ui-icon {background-image: url(images/222222_256x240_icons_icons.png); }
#widget-docs .ui-widget-header .ui-icon {background-image: url(images/222222_256x240_icons_icons.png); }
#widget-docs .ui-state-default .ui-icon { background-image: url(images/888888_256x240_icons_icons.png); }
#widget-docs .ui-state-hover .ui-icon, #widget-docs .ui-state-focus .ui-icon {background-image: url(images/454545_256x240_icons_icons.png); }
#widget-docs .ui-state-active .ui-icon {background-image: url(images/454545_256x240_icons_icons.png); }
#widget-docs .ui-state-highlight .ui-icon {background-image: url(images/2e83ff_256x240_icons_icons.png); }
#widget-docs .ui-state-error .ui-icon, #widget-docs .ui-state-error-text .ui-icon {background-image: url(images/cd0a0a_256x240_icons_icons.png); }


/* Misc visuals
----------------------------------*/

/* Corner radius */
#widget-docs .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; }
#widget-docs .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; }
#widget-docs .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; }
#widget-docs .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; }
#widget-docs .ui-corner-top { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; }
#widget-docs .ui-corner-bottom { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; }
#widget-docs .ui-corner-right {  -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; }
#widget-docs .ui-corner-left { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; }
#widget-docs .ui-corner-all { -moz-border-radius: 4px; -webkit-border-radius: 4px; }

/* Overlays */
#widget-docs .ui-widget-overlay { background: #aaaaaa url(images/aaaaaa_40x100_textures_01_flat_0.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); }
#widget-docs .ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/aaaaaa_40x100_textures_01_flat_0.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; }

/*
----------------------------------*/

#widget-docs { margin:20px 0 0; border: none; }

#widget-docs h2, #widget-docs h3, #widget-docs h4, #widget-docs p, #widget-docs ul, #widget-docs code { margin:0; padding:0; }
#widget-docs code { display:block; color:#444; font-size:.9em; margin:0 0 1em; }
#widget-docs code strong { color:#000; }
#widget-docs p { margin:0 3em 1.2em 0; }
#widget-docs p.intro { font-size:13px; color:#666; line-height:1.3; }
#widget-docs ul { list-style-type: none; }

#widget-docs h2 { font-size:16px; margin:1.2em 0 .5em; }
#widget-docs h3 { font-size:14px; color:#e6820E; margin:1.5em 0 .5em; }
.normal #widget-docs h4 { font-size:12px; color:#000; border:0; margin:0 0 .5em; }

#docs-overview-main { width:400px; }
#docs-overview-sidebar { float:right; width:200px; }
#docs-overview-sidebar a span { color:#666; }
#widget-docs #docs-overview-main p { margin-right:0; }
#widget-docs #docs-overview-sidebar h4 { padding-left:0; }

.docs-list-header { float:left; width:100%; margin:10px 0 0; border-bottom:1px solid #eee; }
#widget-docs .docs-list-header h2 { float:left; margin:0; }
#widget-docs .docs-list-header p { float:right; margin:5px 0; font-size:11px; }

.docs-list { float:left; width:100%; padding:0 0 10px; }
.docs-list .param-header { float:left; clear:left; width:100%; padding:8px 0; border-top:1px solid #eee; }
#widget-docs .param-header h3, #widget-docs .param-header p { margin:0; float:left; }
#widget-docs .param-header h3 { width:50%; }
#widget-docs .param-header h3 span { background: url(images/demo-spindown-closed.gif) no-repeat left; padding-left:13px; }
#widget-docs .param-open .param-header h3 span { background: url(images/demo-spindown-open.gif) no-repeat left; }
#widget-docs .param-header p { width:24%; }
#widget-docs .param-header p.param-type span { background: url(images/icon-docs-info.gif) no-repeat left; cursor:pointer; border-bottom:1px dashed #ccc; padding-left:15px; }

.param-details { padding-left:13px; }
.param-args { margin:0 0 1.5em; border-top:1px dotted #ccc;}
.param-args td { padding:3px 30px 3px 5px; border-bottom:1px dotted #ccc;  }


/* overrides for ui-tab styles */
#widget-docs ul.ui-tabs-nav { padding:0 0 0 8px; }
#widget-docs .ui-tabs-nav li { margin:5px 5px 0 0; }

#widget-docs .ui-tabs-nav li a:link,
#widget-docs .ui-tabs-nav li a:visited,
#widget-docs .ui-tabs-nav li a:hover,
#widget-docs .ui-tabs-nav li a:active { font-size:14px; padding:4px 1.2em 3px; color:#fff; }

#widget-docs .ui-tabs-nav li.ui-tabs-selected a:link,
#widget-docs .ui-tabs-nav li.ui-tabs-selected a:visited,
#widget-docs .ui-tabs-nav li.ui-tabs-selected a:hover,
#widget-docs .ui-tabs-nav li.ui-tabs-selected a:active { color:#e6820E; }

#widget-docs .ui-tabs-panel { padding:20px 9px; font-size:12px; line-height:1.4; color:#000; }

#widget-docs .ui-widget-content a:link,
#widget-docs .ui-widget-content a:visited { color:#1b75bb; text-decoration:none; }
#widget-docs .ui-widget-content a:hover,
#widget-docs .ui-widget-content a:active { color:#0b559b; }





Read More

Operator Overloading in C# Definition with example

Operator Overloading in c# Example 

In this article, I am going to discuss about operator overloading and it's example, Sometimes developers confused about it and they think operator overloading and function overloading is same but both are very different.

Definition of Operator overloading

The class allows creating a user to define the type or extract datatype. If we create a variable of that type is set to be an object but that object doesn't support all the operators it supports few operators like . and (Assignment operator), by using operator loading we can enhance the capabilities of an object to support the operator.


Point: 
1. Operator overloading works on early binding approach.
2. We can't operator overload at that function which approaches decide at run-time.

Why we use operator overloading in c#
Used for to achieve object addition.

Steps for implementing operator overloading in c#
Here is some step that you need to follow while you are implementing operator overloading in c#.

1.The operator is a function is to be applied to support inbuilt operator to given an object
2.The opeartor function should be static(See Example).
3. This function always takes two parameters, can't have three parameters and must be public.
4.Note: We can't overload AND, OR, NOT like logical operator.
5. Operator function returns the object of containing class.

Example of Operator overloading

using System;
class office
{
    double salary;
    public office()
    {
        salary = 0;
    }
    public office(double sal)
    {
        salary = sal;
    }
    public void Display()
    {
        Console.WriteLine(salary);
    }
    public static office operator +(office o,office ob//it must be public static otherwise get compiler error
    {
        office obj = new office();
        obj.salary = o.salary + ob.salary;
        return obj;
    }

    static void Main()
    {
        office a = new office(1212);
        office b = new office(7888);
        office accuntant = new office();
        accuntant = a + b;
        accuntant.Display();

    }
}




READ MORE-KNOW MORE







Read More