Sunday, December 2, 2007

How do I implement client side warning/error messages in Sharepoint 2007

When you invoke Remove Users from Group menu in the Peoples and Groups (Site Actions -> Site Settings -> Peoples and Groups) without selecting any user the below warning message will be displayed.


How it is implemented. The people.aspx page in the <12hive>\ TEMPLATE\LAYOUTS, contains the following js declaration,

var noUserSelectedMsg = "<SharePoint:EncodedLiteral runat='server' text='<%$Resources:wss,people_nouserselected%>' EncodeMethod='EcmaScriptStringLiteralEncode'/>";

when we request the page the people_nouserselected string resource from wss.en-US.resx resource file is assigned to the noUserSelectedMsg. This variable later used in BtnRemoveUsersClick Js function. The Resources:wsss refers to the wss.en-US.resx file. To refer some other resource file replace the wss with your resource file.

To implement your custom resource file you can create a new assembly with you custom resource file, and keep the resx file in your C:\Inetpub\wwwroot\wss\VirtualDirectories\App_GlobalResources folder. Keep the assembly in the GAC, then declare and use as in the above example.


Cheers ,
Murugan G.

No comments: