public void WriteLogError(ExceptionContext filterContext)
        {
            StringBuilder builder = new StringBuilder();
            builder
                .AppendLine("-----------------------------------------------------")
                .AppendLine(DateTime.Now.ToString())
                .AppendFormat("Source:\t{0}", filterContext.Exception.Source)
                .AppendLine()
                .AppendFormat("Target:\t{0}", filterContext.Exception.TargetSite)
                .AppendLine()
                .AppendFormat("Type:\t{0}", filterContext.Exception.GetType().Name)
                .AppendLine()
                .AppendFormat("Message:\t{0}", filterContext.Exception.Message)
                .AppendLine()
                .AppendFormat("Stack:\t{0}", filterContext.Exception.StackTrace)
                .AppendLine();
                .AppendLine("-----------------------------------------------------")

            string filePath = filterContext.HttpContext.Server.MapPath("~/App_Data/Error.log");
            using (StreamWriter writer = File.AppendText(filePath))
            {
                writer.Write(builder.ToString());
                writer.Flush();
            }
        }


 <%= Html.DropDownListFor(model=>model.Color, new List<SelectListItem> {                
                                                                 new SelectListItem{ Text="Red", Value = "1" },
                                                                  new SelectListItem{ Text="Black", Value = "2" },
                                                                   new SelectListItem{ Text="White", Value = "3" }
                                                        },"Select", new { @class="form-control"}) %>

<asp:GridView ID="Grid_product" runat="server" OnRowDataBound="Grid_product_RowDataBound"  AutoGenerateColumns="true">
  </asp:GridView>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ArrayList arrl = new ArrayList();
                arrl.Add("Profit"); arrl.Add("Lost"); arrl.Add("Null");                                 arrl.Add("Null"); arrl.Add("Lost"); arrl.Add("Profit"); al.Add("Profit");                this.Grid_product.DataSource = arrl;
                this.Grid_product.DataBind();
            }
        }

 protected void Grid_product_RowDataBound(object sender, Grid_productRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[0].Text == "Profit")
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Red;
                }
                else if (e.Row.Cells[0].Text == "Lost")
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Black;
                }
                else
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Green;
                }
            }
        }
the javascript on code behind alert message with page redirect on the following code

ScriptManager.RegisterStartupScript(this,this.GetType(),"redirect",
"alert('Registration Successfully !'); window.location='" + 
Request.ApplicationPath + "Default.aspx';",true);

This is a program code which will provide info about -Ajax calender extender with java script to the developer.It will mostly used to select dates like birthdate.If user wants to select any dates prior to current date then s/he will not able to select any future date.


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>devloper4u</title>

    <script type="text/javascript">
        function CurrentDateShowing(e) {
            if (!e.get_selectedDate() || !e.get_element().value)
                e._selectedDate = (new Date()).getDateOnly();
        }     
    </script>

    <script type="text/javascript">
        function CheckDateEalier(sender, args) {
            if (sender._selectedDate > new Date()) {
                alert("Day earlier than today cannot be selected.");
                sender._selectedDate = new Date();
                sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }
        }
        
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
      <asp:TextBox ID="txtDOB" runat="server"></asp:TextBox>
                                <asp:ImageButton ID="Imgbutton1" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" />
                                <cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy" PopupButtonID="Imgbutton1"
 TargetControlID="txtDOB" OnClientDateSelectionChanged="CheckDateEalier">
                                </cc1:CalendarExtender>
    </div>
    </form>
</body>
</html>