|
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebPartPages;
namespace UserControl_WebPart
{
public class UCwebpart : WebPart
{
private UsercontrolWebPart usercontrol;
private string error = "";
private string Pathofusercontrol = @"/";
protected override void CreateChildControls()
{
try
{
string tooldir = this.Page.Request.MapPath(Pathofusercontrol);
string[] textArray1 = null;
try
{
textArray1 = Directory.GetFiles(tooldir);
}
catch (Exception exception1)
{
error += string.Format(exception1.ToString());
return;
}
usercontrol = (UsercontrolWebPart)this.Page.LoadControl(Pathofusercontrol + @"UsercontrolWebPart.ascx");
Controls.Add(usercontrol);
}
catch (Exception CreateChildControls_Exception)
{
error += "CreateChildControls_Exception 2: " + CreateChildControls_Exception.Message + " - Path is" + Pathofusercontrol.ToString() + "--End";
}//end catch
base.CreateChildControls();
}
protected override void RenderContents(HtmlTextWriter writer)
{
try
{
base.RenderContents(writer);
}
catch (Exception RenderContents_Exception)
{
error += RenderContents_Exception.Message;
}
finally
{
if (error.Length > 0)
{
writer.WriteLine(error);
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Gaurav Mehta is from Delhi, India. He has to his credit, a Bachelor’s Degree in commerce and a Master's in Computer and Software Applications. He started his career with C and C++ and then moved on to Microsoft Technologies. He has been in this industry for more than 6.5 years. Gaurav is primarily involved in requirement analysis; designing and developing web and win apps.
http://www.GauravMehta.com
http://www.GauravMehtasBlog.com