Display Calendar view using sharepoint in C# script.

  1. <script type="text/c#" runat="server">  
  2.   
  3. string strListName = "Courses";  
  4.  string strView = "All Items";  
  5. protected void Page_Load(object sender, EventArgs e)  
  6. {  
  7.     GenerateListViewWp();  
  8. }  
  9. void btnview_Click(object sender, EventArgs e)  
  10. {  
  11.          
  12.               
  13.              string strTitle = "Course Calendar";  
  14.            
  15.              SPWeb oWeb = SPContext.Current.Web;  
  16.              SPList oList = oWeb.Lists[strListName];  
  17.              SPView View = oList.Views[strView];  
  18.               ListViewWebPart wp = new ListViewWebPart();  
  19.              wp.ListName = oList.ID.ToString("B").ToUpper();  
  20.              wp.ViewGuid = oList.Views[View].ID.ToString("B").ToUpper();  
  21.              wp.ID = this.ID + "child";  
  22.              ////wp.Title = "";  
  23.              wp.ViewType = ViewType.Calendar;  
  24.           wp.GetDesignTimeHtml();  
  25.     this.PageCalendarDiv.Controls.Add(wp);  
  26.      
  27.    }  
  28.      
  29.    }  
  30.    </script>  
  31.     
  32.      
  33.    <div id="PageCalendarDiv" runat="server">  
  34.    </div>