技术开发 频道

在MOSS 2007中开发和使用Web User控件


    接下来,我们重载从WebPart类继承来的RenderContents方法。选这个方法是因为,在SharePoint网页的生命周期中,当这个方法被调用时所有的先决条件都已经发生,包括创建和分配SharePoint变量,以及CreateChildControls方法。由于当这个方法被SharePoint ASP引擎调用时子控件总是存在,所以没必要在这里调用EnsureChildControls。
protected override void RenderContents(HtmlTextWriter writer) 
{
// not much to do here except to programmatically and cleanly
// handle exceptions
try
{
base.RenderContents(writer);
}
catch (Exception RenderContents_Exception)
{
_exceptions += "RenderContents_Exception: " + RenderContents_Exception.Message;
if (AlwaysBubbleUpExceptions)
{
throw;
}
}
finally
{
if (_exceptions.Length > 0 && AutoWriteExceptions)
{
writer.WriteLine(_exceptions);
}
}//end try/catch/finally
}//end protected override void RenderContents(HtmlTextWriter writer)
签署和建立工程

   我们还没准备好建立类。因为我们打算让WebPart和Web User控件位于微软Office SharePoint Server和Global Assembly Cache里。我们需要分配一个Strong Name key并签署控件。在Solution Explorer中,在SmartParticles工程点上点击右键,选择属性,工程属性页面就会打开。在左边的选项中选择Signing标签。查看并确保“Sign the assembly”框被选中,然后在"Choose a strong name key file"的下拉列表中选择<New...>。


0
相关文章