Using Crystal Report in ASP.net MVC and creating generic report viewer

Download Project
This article describes how to show crystal report in ASP.net MVC.
Here I will describe two different ways for showing crystal report in MVC.
1. Showing crystal report using ASP.net web forms in MVC.
    A. In same window
    B. In different window
2. Showing crystal report from Controller/action (by generating PDF on fly).
    A. In same window
    B. In different window

Later I will describe how to create a generic/ common report viewer web form and generic/ common report viewer Controller class, which will be used for showing any Crystal report (with/ without data).

Continue reading

Master Detail CRUD Operations using ASP.net MVC 3 and EF

Master Detail CRUD Operations using ASP.net MVC 3 and EF. Master detail in asp.net mvc

Introduction

In this post I will discuss about how we can perform Master Detail CRUD Operations using ASP.net MVC 3 and Entity Framework (Code First).  Here I have used JSON (json2.js)  for data passing, Ajax for posting and DataTables (datatables.js) for manipulating detail Record.

Continue reading

My Short Note

Use Asp.net Session from Class Library (or Class Library Project)

Add First we need to add System.Web as a reference on our project.

System.Web.HttpContext.Current.Session[“MyVariable”];
System.Web.HttpContext.Current.Session(“MyVariable”);

Continue reading

Preventing / Blocking Page Review after Logout with Forms Authentication

After logging out we can prevent getting previous page or information by doing following things.

Add Code to Page Load event:
—————————–

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

Or We can use following code
Continue reading

Export to pdf ( Create pdf on fly ) using ASP.net and C#

Consider following code for creating pdf document on fly using ASP.net in C#.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

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

 Continue reading 

How to enable Paging in GridView in ASP.net or Grid View Paging doesn’t work

Do Following steps.

–> Set EnablePaging and Sorting Callback = True from Propertise.
Set your data source as general way.

Now do another extra job for working paging
Write down the following code under PageIndexGhanging Event

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
      //Create your data set or table as u did 
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }