Wednesday, June 3, 2009

Change Stylesheet of a web part

. Wednesday, June 3, 2009
0 comments

When we add a style sheet to webpart through code, it overrides the main stylesheet of the page. However there’s a workaround approach through we can restrict styles to only one webpart.

Every webpart has a Zone Cell Id reference “MSOZoneCell_WebPart_WPQ_”. The _WPQ_ portion is replaced by the webpartzone name during the execution of the code. This can be checked by viewing the source of the webpartpage. So it would become something like #MSOZoneCell_WebPartWPQ3.

Through view source property we can find the id of the webpart to which we want to add our styles.

Suppose our webpartpage has two webparts with a table each and we want to apply styles only to the second webpart. In usual cases the stylesheet, if supplied in the webpart code, is applied to the whole page, which is not required.

The solution:

1. What we can do is, to add a Content Editor Webpart, and supply the style definitions for that particular webpart in its source editor. This webpart can be hidden.

Now again if we supply a style something like:

<style>

TABLE

{

            font-weight: normal;

            color: navy;

            font-family: 'Bookman Old Style';

            background-color: #ccccff;

}

</style>

It would be applied to the whole page. The solution is that we can use the id of this particular webpartzone (MSOZoneCell_WebPartWPQ3).(it is fixed and can be obtained through view source property if the webpart page.

Hence we can have something like:

<style>

/*changes the header of the wbepart*/

#MSOZoneCell_WebPartWPQ3 .ms-WPTitle

{

    font-weight: bold;

    font-family: verdana, arial, helvetica, sans-serif;

    color: #00ccff;

    padding-left: 6px;

    padding-right: 7px;

    padding-top: 2px;

    padding-bottom: 2px;

    font-size: 8pt;

background-color: teal;

}

/*changes the body of this webpart only, if it contains any td tag.*/

#MSOZoneCell_WebPartWPQ3 .ms-WPBody TD

{

            border-right: thin groove;

            padding-right: 1px;

            border-top: thin groove;

            padding-left: 1px;

            padding-bottom: 1px;

            margin: 2px;

            border-left: thin groove;

            padding-top: 1px;

            border-bottom: thin groove;

}

#MSOZoneCell_WebPartWPQ3 .ms-WPBody th

{

    font-size: 8pt;

    font-family: verdana, arial, helvetica, sans-serif;

    background-color: #cc0033

}

/*since datagrid is rendered as a table , hence we can provide a custom class here for datagrid. This clas can be set as the cssclass of the datagrid in the webpart code.*/

.skynetdatagrid {

font-size: 12pt;

            color: silver;

            font-family: verdana, arial, helvetica, sans-serif;

            background-color: black;

}

.skynettable

{

            font-weight: bold;

            color: green;

            background-color: #ffccff;

}

</style>

Error while moving documents across site collections, sites - cannot read from source file or disk

.
0 comments

Using windows explorer one cannot drag n drop (cut-paste) documents across site collections.

If you try to cut-paste (drag-drop) documents across site collections or across sites in same site collection, you would get the following error: -

"cannot read from source file or disk"

WORKAROUND

1) Open the source and destination libraries as network places. (using add a new network place).

2) Browse to the document libraries in question.

3) Drag-drop the files.

4) There’ll be no error.

Things to check at client’s end: -

1) Check if Webclient service is running and is set to auto start in services.msc. Stop and restart it.

Workflow error - Failed to load the workflow

.
0 comments

Existing workflows when opened through SharePoint Designer throw the following error : -

Steps to be taken : -

1) Ensure if you always get this error or if it is intermittent.

2) In case of the latter, try creating new workflow and see if any of the ECF custom actions are missing from the list.

3) If yes, try pointing to all WFEs (in case of load balancing) currently servicing that web application and see if the issue is replicated.

Digital Signatures in Infopath form templates - self signing

.
1 comments

For internally developed applications, we would not want to buy digital certificates and sign the InfoPath form templates using them. Hence comes the concept of self signing the form templates. However this has to be used strictly for testing purposes only.

1) Download the Microsoft Platform SDK for Windows Server 2003 R2 from Microsoft site.

2) Use the makecert utility located in the C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Bin folder.

makecert -sk <key file store location name> -n "CN=TestCertificate for Himani" certificate1.cer -ss my -pe

3) Now the certificate will be available in the “personal folder. You can use signtool.exe’s signwizard to sign the form template with this certificate. You need to select the certificate from the personal store and select the private key store location.