Wednesday, June 3, 2015

  Response.Redirect should be used when:


   1: we want to redirect the request to some plain HTML pages on our server or to some other web      server

   2: we do not care about causing additional round-trips to the server on each request

   3: we do not need to preserve Query String and Form Variables from the original request

   4: we want our users to be able to see the new URL redirected where he is redirected in his browser (and be able to bookmark it if its necessary)

   Server.Transfer should be used when:


   1: we want to transfer current page request to another .aspx page on the same server

   2: we want to preserve server resources and avoid the unnecessary round-trips to the server

   3: we want to preserve Query String and Form Variables.

   4:we do not need to show the real URL where we redirected the request in the users Web Browser
Building ASP.NET Reporting OLAP-Based Application.


This is best study materiel abou OLAP reporting services.


http://www.codeproject.com/Articles/35727/Building-ASP-NET-Reporting-OLAP-Based-Application

 


 

 

 

 

Tuesday, June 2, 2015

Encode Asp Lable Using Server.HtmlEncode in C#


string encodedlabel = Server.HtmlEncode(textlabel.Text);

How to Export DataTable to Excel file in C#.net.

 In this method we pass only datatable and file name.This will export whole datatable to excel file with given name.
Try this......................

 public void ExportToExcel(DataTable dt, string filename)
        {


            Response.Clear();
            Response.Charset = "";
            //Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.Write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
            Response.AddHeader("content-disposition", "attachment; filename=" + filename + "");
            Response.ContentType = "application/vnd.xls";
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            GridView g = new GridView();

            DataTable d = new System.Data.DataTable();


            g.AllowPaging = false;

            DataTable dtExport = new DataTable();
            dtExport = dt;

            g.DataSource = dtExport;
            g.DataBind();
            if (dtExport.Rows.Count > 0)
            {
                //Change the Header Row back to white color
                g.HeaderRow.Style.Add("background-color", "#FFFFFF");
                //Applying stlye to gridview header cells
                for (int i = 0; i < g.HeaderRow.Cells.Count; i++)
                {
                    g.HeaderRow.Cells[i].Style.Add("background-color", "#00ab96");
                    g.HeaderRow.Cells[i].Style.Add("color", "#FFFFFF");
                }
                int j = 1;
                //This loop is used to apply stlye to cells based on particular row
                foreach (GridViewRow gvrow in g.Rows)
                {
                    gvrow.BackColor = Color.White;
                    if (j <= g.Rows.Count)
                    {
                        if (j % 2 != 0)
                        {
                            for (int k = 0; k < gvrow.Cells.Count; k++)
                            {
                                gvrow.Cells[k].Style.Add("background-color", "#EFF3FB");
                                //gvrow.Cells[k].Style.Add("color", "#FFFFFF");
                            }
                        }
                    }
                    j++;
                }
                g.RenderControl(htmlWrite);
                Response.Write(stringWrite.ToString());
                Response.End();
                Response.ClearContent();
                Response.Buffer = true;
                Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "+filename+"));
                Response.ContentType = "application/ms-excel";
                StringWriter sw = new StringWriter();
                HtmlTextWriter htw = new HtmlTextWriter(sw);
            }
            else
            {
                //
            }
        }

 

 

Face Recognition Using Open CV

How we recognize in android.
Download link 
https://github.com/Ajay191191/Opencv-Face-Recognition 

Monday, June 1, 2015

How we get the Full Name from LDAP in C#.net.
string strName = Page.User.Identity.Name.ToString();

Remove duplicates values from array.

int[] sa = { 1, 2, 3, 3, 4};
int[] q = sa.Distinct().ToArray();