• Category Archives C#
  • Sharepoint 2010 UI Customizations – Hide Entire Ribbon On a Single Page

    I found myself in a scenario that required me to hide the entire ribbon from the New Item form in SharePoint. Below is a simple solution to this issue.

    1) Open the list file in SharePoint Designer and open in advanced mode.
    2) Under the Manage Styles window, select New Style.

    3) Add the style #s4-ribbonrow and apply the attribute (display: none;).

    4) Save the .aspx file and view it in your browser.



  • WSS v3 – Trusted Site Authentication & DN Registration within WSS

    IE Auto login or Pass-through authentication has just a couple rules:

    1) Any address, added to internal DNS or even your own computer, that includes a “.com” in it, will make the browser think its outside the network and thus disable the passthrough authentication from your domain.

    2) Pass-through Authentication must be enabled within IE. “User Authentication” can be pushed out via a group policy if you wish.

    (Yes…I made the horriffic mistake of installing IE8. The gnomes made me do it!)

    pass-through authentication 1









































    ***NOTE: The downfall to this is if it IS enabled, WSS will not pull any data from Active Directory excluding username & password. Email addresses and other AD account values will not pull across into the User Information List. Take the good with the bad.

    On the SharePoint site, you also might want to give your site a title coolname.domain.com. In which case…you make the modification, here… (oh yeah, a restart of IIS services may be needed)
    access mappings



  • WSS v3 – Adding PDF Indexing and Show PDF Icon

    After a bit of mucking about with the Searching & Indexing setting, I will explain about this in another blog entry soon, I got the site search to work correctly.

    icon_pdfI noticed that PDF documents weren’t being returned in any of my searches.  Not only this but it also appeared that PDF files were totally unsupported in MOSS as they would not display an icon in my document libraries.

    This is because when MOSS crawls content it needs to open each document to index its contents, it does this by using an iFilter (very Appleesk).

    You can get PDF iFilters from Adobe but a company called FoxIt have released both x86 & x64 versions of a PDF iFilter.  You can download that from their website.  www.foxitsoftware.com

    Adding a Document Icon

    1. Save a copy of an image you wish to see as the PDF document icon to “Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12TemplateImagespdf.gif” – Images should be 15×15 pixels in size.
    2. Navigate to “Program FilesCommon FilesMicrosoft SharedWeb server extensions12TemplateXml”
    3. Edit “DOCICON.XML” in notepad
    4. Add the following line <Mapping Key=”pdf” Value=”pdf.gif”/>
    5. Open a Command Prompt and type “iisreset”  – NOTE : this will temporarily stop MOSS from being accessed while IIS restarts.

    iFilter Installation Steps

    1. Stop the IIS Admin service(s) – NOTE : No one will be able to access MOSS until after Step 3 has been completed.
    2. Install FoxIt’s iFilter on all indexing servers
    3. Open a Command Prompt and type “iisreset”
    4. Open the MOSS Central Administration Site
    5. Go to the Share Service Administration Site running the search service
    6. Select “Search Settings”
    7. Select “File Types”
    8. Select “Add New File Type”
    9. Enter “pdf” click OK
    10. Now run a Full Crawl
    11. Check the Crawl Log to see that PDF files are successful indexed

    Thanks to Matt for this patch documentation!



  • WSS v3 – Custom Site Theme for WSS 3.0 & 2007

    The easiest and the fastest way to apply the same look and feel on any SharePoint site is creating a site theme. A SharePoint site theme basically consists of theme.inf, theme.css, and image files. Theme.inf file simply represents the title of the theme. Theme.css is a stylesheet file that defines colors, header images and layouts of a site and image files can be referenced here to display on the page. By creating a custom site theme, you can easily change the style but in fact, writing and editing the stylesheet can be somewhat chanllenging when you have more than a hundred of elements to deal with.

    Here is a short procedure of creating a custom site theme named “Ghost”:

    1. Copy any theme folder in “C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATETHEMES” folder and paste with its name replaced with “Ghost”. In this example, copy GRANITE folder.

    2. In Ghost folder, rename GRANITE.INF file to GHOST.INF in upper case.

    3. Open GHOST.INF file with notepad.

    4. Change the value of title under [Info] to Ghost.

    5. Replace every word, Granite, under [titles] with Ghost.

    6. Open “C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATELAYOUTS1033SPTHEMES.XML” file with notepad.

    7. Add the following lines under <SPThemes> tag:
     <Templates>
      <TemplateID>Ghost</TemplateID>
      <DisplayName>Ghost</DisplayName>
      <Description>Ghost theme.</Description>
      <Thumbnail>images/thghost.gif</Thumbnail>
      <Preview>images/thghost.gif</Preview>
     </Templates>
    Notice that preview and thumbnail paths are images/thghost.gif. By default, MOSS 2007 and WSS 3.0 will not have such image files.

    8. In order to display thumbnail and preview correctly, you will need to capture the screen and save the file in “C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEIMAGES” folder with thghost.gif name. You can change the .gif file name if you change the thumbnail and preview file names in <Templates> tag.

    9. Do an iisrest for the server to recognize the new theme.

    Pretty simple procedure. Now you are ready to test your new theme. In Site Settings, you can now choose Ghost theme; however, the theme will not differ from Granite theme. Now, it is time for you to play with theme.css file!



  • WSS v3 – Adding Line Break to a Survey

    I came across this little issue this week and found a solution that tested successfull. It is quite easy to implament. The only possible downside is that it isn’t going to effect the entire site collection if the heiarchy is broken….

    Thanks! Mark Deraeve

    by mderaeve 23. May 2009 02:37

    A user is trying to make a survey. Now, she needed to create a header for each new page in the survey. She tried to use the textbox and hit enter in the question field, that’s what I would do to. And it appears as if the enter are accepted. But when you look at the question, you will notice that the line break disappeared. As I was looking for a solution, I found that in the previous version, this was possible but not in WSS 3.0! So after looking a little more, this site gave a good solution, I decided to use it, but with a slightly different approach.

    The thing is that we will implement a javescript that will look for elements with classname : ‘ms-formlabel’. Then it will replace the word linebreak with a <BR>. This solution you can find on the site I mentioned above. But they suggest to place a content editor webpart on each page that uses the survey, like the newform.aspx of each survey. Since I’m using a WSS site specially for surveys, I don’t want to do this every time I create new survey. So I added the code to the default masterpage of the site. In the head section of the page I placed a function called: setLineBreaks()

    <HEAD runat="server">
                …
                <script>
                function setLinebreaks()
                {
                            var className;
                            className = 'ms-formlabel';
    
    
                            var elements = new Array();
                            var elements = document.getElementsByTagName('td');
    
    
                            for (var e = 0; e < elements.length; e++)
                            {
                            if (elements[e].className == className){
                            elements[e].innerHTML = elements[e].innerHTML.replace(/linebreak/g,'<br/>');}
                            }
                }
                </script>
    </HEAD>
    
    

    Then I call this function on the pageload event like this (the code I added is in bold):

    <BODY scroll="yes"
    onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();setLinebreaks();">
    
    

    So now every time you enter the word linebreak in a question a new line will be started. (It will be replaced with a <br>)

    Some screenshots of the results:

    linebreaklinebreak2



  • WSS v3 – Moving A WSS v3 Database

    My company provided me a very old server with two hard drives. The C drive is about 30 gig, the other about 72 gig. I found the task of moving my database was needed shortly after launch of the SharePoint server. The database I setup had already reached up to 2.3 gig. Which meant the page file was going to reach ATLEAST that.  Reading and writing from both the page file and the database files from the same drive didn’t make much sense to me either. So, I began to research the move process.

    I found a couple sources that had the information I needed. I have to say that Chicagotech.net had an excellent resource on moving a database. Kudos to you guys! Their process was quite flawless on the database site. For the WSS application itself, it required a little bit more.

    Before you cut off the database and move it, you need to shut down some if the Sharepoint services. I listed the script below for your refrence. Though, your services might not be named the same as mine, they probably are the same as I didn’t stray from the norm on my WSS configuration. Excluding configuring it to be used as a farm later on.

    The biggest oversite I found, that nobody mentioned, was that the database files will lose their Windows security permissions. Make sure you apply the Sharepoint service accounts full access to the two database files (I list this at the end of the process).

    1) Stop all Sharepoint Services….

    net stop SPAdmin
    net stop SPWriter
    net stop SPTimerV3
    net stop SPSearch
    net stop SPTrace
    net stop MSSQL$YourSharepointDbNameHere

     

    2) Detach the database….

    sql2















    >






    3) Move the database…

    xcopy “C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataWSS_Content.mdf” E:WSS_ContentWSS_Content.mdf /v /f
    xcopy “C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataWSS_Content_log.LDF” E:WSS_ContentWSS_Content_log.LDF /v /f

     

    4)Configure the proper windows Sharepoint service account’s security permissions to the moved MDL & LDF files.

    5) Reattach the database…

    sql3
    >





    >








    6) Start all Sharepoint Services….


    net start SPAdmin
    net start SPWriter
    net start SPTimerV3
    net start SPSearch
    net start SPTrace
    net start MSSQL$YourSharepointDbNameHere