Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Print Function create custom web parts View modes: 
User avatar
Member
Member
oli.acev-yahoo - 5/19/2010 5:40:26 AM
   
Print Function create custom web parts
I want to create Print function WebParts but I can to complete and I need some help.
I was created PrintFunctions.ascx page with this code

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="PrintFunctions.ascx.cs" Inherits="CMSWebParts_Viewers_PrintFunctions" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<script type='text/javascript'>
<!--
function printPage()
{
var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;

if(!pr)
return;

var printArea = document.getElementById("mainareadiv");

if(printArea == null && da)
printArea = document.all.mainareadiv;

if(printArea)
{
var sStart = "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>styles/structure.css\"><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>styles/editor.css\"><link rel=\"stylesheet\" type=\"text/css\" href=\"<%=Configuration.RootDir%>styles/units.css\"></head><body onload=\"javascript:window.print();\">";
sStop = "</body></html>";

var w = window.open('','printWin','width=650,height=440,scrollbars=yes');
wdoc = w.document;
wdoc.open();
wdoc.write( sStart + printArea.innerHTML ) ;
wdoc.writeln( sStop );
wdoc.close();
}
}
//-->
</script>


and code behind PrintFunctions.ascx.cs with this code:

using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


namespace CMSWebParts_Viewers_PrintFunctions
{
/// <summary>
/// Summary description for PrintFunctions.
/// </summary>
public abstract class PrintFunctions : UserControlBase
{

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}



I have this error Could not load type CMSWebParts_Viewers_PrintFunctions


Please help me hoe to complete this web parts

Thanks

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 5/23/2010 12:45:17 PM
   
RE:Print Function create custom web parts
Hello,

Could you please try to change name of your class to CMSWebParts_Viewers_PrintFunctions and set it to inherit from CMSAbstractWebPart class? You can find instructions how to create new web part at http://www.kentico.com/docs/devguide/developing_web_parts.htm.

Best Regards,

Martin Dobsicek