CHUVASH.eu
  • About
  • Search

Posts

October 6, 2011

Good pattern for javascript files

SP.js exists in two variants in debug mode and in modified. When you develop it is better to use debug mode. When it goes to production it is better to use minified files. The same you can do with your files. Wictor Wilen explains how to do minify your custom javascript files. I think it is a good pattern to create javascript files and call them something-something**.debug.js**. Then when you are done, run the custom tools to minify them.

read more
October 6, 2011

Show html in ModalDialog

We can use ModalDialogs to show not only pages, but some html:

var htmlElement = document.createElement('p');

var helloWorldNode = document.createTextNode('Hello world!');
htmlElement.appendChild(helloWorldNode);

var options = {
	html: htmlElement,
	autoSize:true,
	allowMaximize:true,
	title: 'Test dialog',
	showClose: true,
};

var dialog = SP.UI.ModalDialog.showModalDialog(options);
read more
October 6, 2011

Custom PlaceHolder

You want some custom content in your site and it is different from page to page. Well, I wrote how to achieve this with delegate controls. Another approach is to use PlaceHolders. Maybe you can use some existing placeholders. There are so many unused placeholders in v4.master. Like PlaceHolderLeftActions. If you use starter master pages from Randy Drisgill, you must move these from invisible panel. To create custom placeholder is very easy: Just copy an existing placeholder in the master page and name it som appropriate like:

read more
October 5, 2011

Create your own search box

It is very simple. Create a new module: SearchArea. Delete Sample.txt and Elements.xml. Create a new file: SearchArea.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Control
      Id="ContosoSearchAreaBox"
      Sequence="15"
      ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" 
      ControlAssembly="Microsoft.Office.Server.Search, Version=14.0.0.0, 
			Culture=neutral, PublicKeyToken=71e9bce111e9429c">
    <Property Name="GoImageUrl">/\_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="GoImageUrlRTL">/\_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="GoImageActiveUrl">/\_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="GoImageActiveUrlRTL">/\_layouts/images/Contoso/searchbutton.png</Property>
    <Property Name="DropDownMode">HideDD\_useDefaultScope</Property>
    <Property Name="FrameType">None</Property>
    <Property Name="UseSiteDefaults">false</Property>
  </Control>
</Elements>

Next add your searcharea module to a site scoped feature.

In the masterpage locate this:

<SharePoint:DelegateControl runat="server" 
       ControlId="SmallSearchInputBox" Version="4" />

and replace with your brand new search area:

read more
October 5, 2011

Link to Home on Top Navigation Bar

If you have a custom site definition and want to have a link to RootWeb, just add NavBarPage to your module:

<Module Name="OrklaRootBlank" Url="" Path="">
  <File Url="default.aspx">
	<NavBarPage Name="$Resources:core,nav\_Home;"
		Url="~site" ID="1002" Position="Start" />
  </File>
</Module>
read more
October 3, 2011

Format with xslt

Here is a good example what we can do with xslt.

read more
September 30, 2011

Add local admin in cmd

Just run this in cmd, or powershell:

net localgroup Administrators /add domainname\\users
read more
September 30, 2011

Check if a file exists

var imgName = "hello.jpg";
var folder = web.GetFolder("PublishingImages");
var img = web.GetFile(folder.ServerRelativeUrl + "/" + imgName);
if (img.Exists) {
  doSomething();
}
read more
September 29, 2011

Todolist in VS

A really nice feature is a task list. Just write //TODO something something in your code and it appears in the task list which can be shown through View - Task List in Visual Studio.

read more
September 29, 2011

Sharepoint Warmup Script

It is useful to warm up a site after app pool recycling or after a site creation in development environments. I found a very simple script which I made even simpler:

$url = "http://takana"
$wc = new-object net.webclient
$wc.credentials = \[System.Net.CredentialCache\]::DefaultCredentials
$wc.DownloadString($url) | out-null
$wc.Dispose()

For more sophisticated warmups Wahid Salemi provided an interisting script to warm up your Sharepoint. By the way. Let us save it as a powershell function. Take a look at sharepointryan’s functions. Let’s create a proper function of that:

read more
  • ««
  • «
  • 35
  • 36
  • 37
  • 38
  • 39
  • »
  • »»
© CHUVASH.eu 2026