Showing posts with label WebPart. Show all posts
Showing posts with label WebPart. Show all posts

Monday, May 3, 2010

Problem with MOSSRadEditor base class in RadEditor for MOSS 4.5.6

Problem with MOSSRadEditor base class in RadEditor for MOSS 4.5.6

I tried to add MOSSRadEditor in sample WebPart so I downloaded ASP.NET RadEditor for MOSS Lite Edition from below free Telerik Control link.
http://www.telerik.com/community/free-products.aspx
As per MOSSRadEditor help file I got 3 dlls for WSP and add to my WebPart project but I can’t find MOSSRadEditor Constructor as below
MOSSRadEditor objMOSSRadEditor = new MOSSRadEditor(); //not define MOSSRadEditor Constructor


Error:
The type 'Telerik.SharePoint.MOSSRadEditor' has no constructors defined

Resolution: I googled this problem and found the problem reason (WSP contains light DLLs). So I got one Telerik Support link (http://www.telerik.com/community/forums/sharepoint-2007/full-featured-editor/problem-with-mossradeditor-base-class-in-radeditor-for-moss-4-5-6.aspx ).This link contains one Reference code which use FULL DLLs so I download this DLLs and use it in my WebPart code.

Result: Its working fine.

Advantage: MOSSRadEditor Support all Browsers like IE, Firefox, Safari etc (I tried for this 3 browser).

Happy Coding !!!

Monday, July 13, 2009

WebPart Printing

3 Easy Steps to Print your WebPart

  1. Add Content Editor WebPart on your WebPart page in which you want to Print.
  2. Click on Modify Share WebPart then click Source Editor's button and add below code for Print Button.

    < type="button" onclick="javascript:void(PrintWebPart())" value="Print Web Part">
    < language="JavaScript">
    //Controls which Web Part or zone to print
    var WebPartElementID = "WebPartWPQ6";
    //Function to print Web Part
    function PrintWebPart()
    {
    var bolWebPartFound = false;
    if (document.getElementById != null)
    {
    //Create html to print in new window var PrintingHTML = '\n\n';
    //Take data from Head Tag
    if (document.getElementsByTagName != null)
    {
    var HeadData= document.getElementsByTagName("HEAD");
    if (HeadData.length > 0)
    PrintingHTML += HeadData[0].innerHTML;
    }
    PrintingHTML += '\n\n\n';
    var WebPartData = document.getElementById(WebPartElementID);
    if (WebPartData != null)
    {
    PrintingHTML += WebPartData.innerHTML;
    bolWebPartFound = true;
    }
    else
    {
    bolWebPartFound = false;
    alert ('Cannot Find Web Part');
    }
    }
    PrintingHTML += '\n\n';
    //Open new window to print
    if (bolWebPartFound)
    {
    var PrintingWindow = window.open("","PrintWebPart", "toolbar,width=800,height=600,scrollbars,resizable,menubar");
    PrintingWindow.document.open();
    PrintingWindow.document.write(PrintingHTML);
    // Open Print Window Printing
    Window.print();
    }
    }
    < /script>


  3. Find your Web Part DIV ID using View Source on WebPage.

    Ex. - open your WebPart Page and right click on this then click on View Source and then find your WebPart
    using Ctl+F. Then you can get DIV id of your WebPart copy this and Paste on above code mark in Bold line.

    //Controls which Web Part or zone to print
    var WebPartElementID = "..........";

Click here for more details.

Friday, April 24, 2009

Create Custom Policy File for SharePoint WebPart

Now you can run your code without modify FULL trust in WEB.Config file.
Below Steps to create Custom Policy File for WebPart.
  • Copy WSS_Minimal.config fole from ...\12\Config\ folder.
  • Rename to MyCustom_minimal.config.
  • Now Add below Code to this config file as per given location.

Add below code


Code Start Here Code End Here
  • Now Create Your PublicKey's Blob file as per below.
  • Open VS's command Promt and RUN below Command

sn -p YourStongNameFile.snk PublicKeyOnly.snk

YourStrongNameFile.snk = Your Projects SNK
PublicKeyOnly.snk = New creted PublicKey

Now Create Blob as below command.

sn -tp PublicKeyOnly.snk

Now your PublicKey's BLOB created like below (here Example)


Copy New Blob and past in above config file.

  • Put your config file in ...\12\Config\ folder.
  • Add one tag in config file below WSS_Medium,WSS_Minimal trust level like below.

    Also change Trust Level WSS_Minimal to MyCustom_Minimal.


Saturday, April 4, 2009

Create SharePoint WebPart using Visual Studio SharePoint Extension

  • Install Visual Studio SharePoint Extension.
  • Open Visual Studio and create New Project > Select SharePoint as Project Type > Select Web Part project template.
  • Then open Webpart1.cs file and add below things in render method.

protected override void Render(HtmlTextWriter writer)

{

writer.write("My First Web Part.");

}

  • Open Property Window of this project and Go TO Debug Tab and add your site URL to Start browsing with URL http://MyPC:100/MyFistSite/" (As per below Image)







  • Right Click on Project in Solution Explorer and Select Deploy.
  • After Successfully Deploy open your SharePoint site and Add Your First Web Part on your Web Part Page.

Very Easy to work with SharePoint Web Part.