About Me

Having 12 years experience in Microsoft technologies.Since more than 7 years working in SharePoint technologies. Expert in providing consultation for SharePoint projects. Hands on with development and administration.

Thursday, 12 December 2013

Using External Javascript, CSS or Image File in a SharePoint WebParts

Button btn;
Image img;
string imgPath;
// Referring External Javascript
ClientScriptManager cs = Page.ClientScript;
// Include the required javascript file.
if (!cs.IsClientScriptIncludeRegistered("jsfile"))
cs.RegisterClientScriptInclude(this.GetType(), "jsfile", "/_wpresources/javascript/jsscript.js");
btn= new Button();
btn.Text = "Click here";
// specify function name here
btn.OnClientClick = "ButtonClick()";
// Refering External CSS
Microsoft.SharePoint.WebControls.CssLink cssLink = new Microsoft.SharePoint.WebControls.CssLink();
cssLink.DefaultUrl = "/_wpresources/styles/styles.css";
// Using External Image
imgPath = "/_wpresources/images/Imglogo.jpg";
img.ImageUrl = imgPath;
img.ID = "image1";

No comments:

Post a Comment