Showing posts with label Web Part. Show all posts
Showing posts with label Web Part. Show all posts

Monday, 19 December 2011

Scroll any sharepoint list in web part

All you need is a SharePoint web site, a list and a SharePoint designer!the process is really quick and simple - believe me, it will take much less time to do it, then it took me to prep it :)

Step One: take a list, any list (in fact any web part or other content)

links list

Step Two: prepare a site page on which you'll have the list displayed

press "Edit Page" > "Insert" > "Existing List" and select your list

site page?

Step Three: Adjust list web part appearence

select wanted view, disable list toolbar, remove web part frame..

prepare the list visual appearence

list properties

 

Step Four: Open SharePoint Designer

open the site, which contains your page and edit it

edit page

 

Step Five: Find list's web part in code view

code view

Step Six: Add marquee object

in a brief: html marquee object let's you scroll it's content on a web page.

Main attributes:

now you need to "wrap" the list's web part with the marquee element, so:

 

marquee

save the page and you're all done, let it scroll !!!

 

scrolling

it's hard to show scrolling content with an image - so you'll just have to take my word on it

Enjoy

Wednesday, 3 August 2011

Silverlight SharePoint Web Part using the HTML Bridge

Silverlight SharePoint Web Part using the HTML Bridge


I recently ran across an issue with the HTML Bridge and conflicting behavior between IE and Firefox.

HTML Bridge info: http://msdn.microsoft.com/en-us/library/cc645076(v=VS.95).aspx

I had the following code in Silverlight to set a JavaScript variable to a Silverlight web part instance on a SharePoint page. By creating this variable I was able to call and pass in parameters into the Silverlight control from the JavaScript running on the page.






private static void InitializeReceiverJsVariable()
{
string pluginId = HtmlPage.Plugin.Id;if (string.IsNullOrEmpty(pluginId))
throw new Exception("No Silverlight Plugin found!  Ensure the Silverlight plugin has an ID!");

string jsCode = string.Format("var {0} = document.getElementById('{1}').content.{0};", JS_VARIABLE_NAME, pluginId);

HtmlPage.Window.Eval(jsCode);
}

Note: any Silverlight methods that you want call from JavaScript will need to have the [ScriptableMember] property on them. Alternatively you could create a class to house all your Scriptable methods and add the [ScriptableType] property to the whole class.

After compiling and deploying the web part to SharePoint, testing the JavaScript proved to be a success. Internet Explorer was allowing for communication between the Silverlight web part and the document library. Firefox was not allowing this. After several tests and some trial and error it turned out to be an issue with declaring the JavaScript variable from Silverlight. The solution was to declare the JavaScript variable on the page and just set the value from Silverlight instead of creating the variable too.

JavaScript addition:

var slWebPart = null;

Silverlight change:






private static void InitializeReceiverJsVariable()
{
string pluginId = HtmlPage.Plugin.Id;if (string.IsNullOrEmpty(pluginId))
throw new Exception("No Silverlight Plugin found!  Ensure the Silverlight plugin has an ID!");

string jsCode = string.Format("{0} = document.getElementById('{1}').content.{0};", JS_VARIABLE_NAME, pluginId);

HtmlPage.Window.Eval(jsCode);
}

After the change to the web part it worked in IE, Firefox, and Chrome. I still have not figured the exact issue or why you can’t declare the variable using the HTML Bridge, but the work around solved the problem. If you have come across this or know the technical reason, comments are always welcome.