in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

echef

From the cluttered (and clustered) brain of Josef Nielsen... A great place for Food, Friends, and... uh... SharePoint of course!

January 2008 - Posts

  • Image Changes on Hover

    It sees there are a lot of large javascript samples out there to change an image source on mouse over, but they all seem overly complex.  Here's a little one I made recently for a project I was working on:

    <script>
    function imgHover(imgObj,imgSrc){
        imgObj.src=imgObj.getAttribute(imgSrc);
    }
    </script>

    And here's some HTML to demonstrate how to use it:

    <img
        src="
    /PublishingImages/main.jpg"
        out="/PublishingImages/main.jpg"
        over="/PublishingImages/main_01.jpg"
        onmouseover="java-script:imgHover(this,'over');"
        onmouseout="java-script:imgHover(this,'out');"
        alt=""
        border=0
    />

    Change the "java-script" and remove the "-" to make it work... It won't show up on the blog post otherwise (it tries to run it).  I've found it easiest to just embed the script in the master page, then I can use img tag with the extra attributes on any page in my site I want...

  • Security Trimming WebControls and ASP Objects

    I hadn't used this yet, and had cause to this week.  It works slick, and is pretty configurable... I used it to hide the SiteActions button on list pages for members, but not admins, as well as admin web parts embedded in a page.  It works with Web Parts, Web Controls, and other ASP.Net objects (ie. SharePoint:*, etc.).  Wrap the content you want trimmed in the following code (using SPD):

    <Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="BrowseDirectories">
    [Content to Trim]
    </Sharepoint:SPSecurityTrimmedControl>

    You can then swap out the "BrowseDirectories" with whatever you need for the trimming.  Here are the one's I've found handy so far:

    • BrowseDirectories = Anyone but Limited Read (Anonymous is Limited Read)
    • ManageWeb = Site Collection Admins
    • ManageSubwebs = Site Owners
    • AddListItems = Site Members and specified list contributors

    Here's a link to all the defined values in the SPBasePermissions Enum.


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts