In SharePoint 2010, the New/Edit/Display form for lists appear as modal dialogs. This uses the Dialog Platform. The modal dialog concept is used when uploading files and also other places in SharePoint 2010.
We can use the same concept if we want to open a modal dialog from a web part. It is pretty simple!
In the web part code, add a prerender event handler:
public MyWebPart()
{
this.PreRender += new EventHandler(MyWebPart_PreRender);
}
In the prerender handler, register the javascript to open the modal dialog:
private void MyWebPart_PreRender(object sender, System.EventArgs e)
{
if (!Page.ClientScript.IsClientScriptBlockRegistered(OPEN_DIALOG_SCRIPT))
{
string includeScript = @"<script language='javascript'>function OpenDialog(formURL) {var options = SP.UI.$create_DialogOptions(); options.url = formURL; SP.UI.ModalDialog.showModalDialog(options); }</script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), OPEN_DIALOG_SCRIPT, includeScript);
}
}
Now, we just need to associate and invoke the javascript OpenDialog function in a hyperlink or a button click. In the below example, I am creating a hyperlink in CreateChildControls method and invoking the function on the hyperlink click:
protected override void CreateChildControls()
{
HyperLink addListItemLink = new HyperLink();
addListItemLink.Attributes.Add("align", "left");
addListItemLink.CssClass = "ms-sitemapdirectional";
addListItemLink.Text = "Add New Item";
addListItemLink.NavigateUrl = string.Format(@"javascript:OpenDialog('{0}');", sNavigateUrl);
this.Controls.Add(addListItemLink);
}
In the above example, the URL in the sNavigateUrl will open in a modal dialog.
Tuesday, December 28, 2010
Wednesday, June 9, 2010
"An error has occured in approval of changes"
A business user setup the OOB Approval workflow for a document library. The Approval workflow completed fine. However, at the end of the workflow, it gave the "An error has occured in approval of changes" error! After a little bit of playing around, I figured that Content Approval for the document library needs to be enabled in order for the Approval workflow to complete successfully.
Steps to enable Content Approval are:
1. Go to Document Library settings.
2. Click on Versioning Settings under General Settings
3. Set "Require content approval for submitted items?" to Yes
Steps to enable Content Approval are:
1. Go to Document Library settings.
2. Click on Versioning Settings under General Settings
3. Set "Require content approval for submitted items?" to Yes
Monday, May 24, 2010
Site limit in Navigation
By default, the quick launch and top navigation bar only show a maximum of 50 sub-sites. This is related to the sitemap's provider DynamicChildLimit property. Setting the DynamicChildLimit property value to "0" will remove this limit and the navigation bars will list the sub-sites.
This is the piece of the web.config with the DynamicChildLimit property set to 0:
< siteMap defaultProvider="CurrentNavSiteMapProvider" enabled="true" >
< providers >
....
....
....
< add name="GlobalNavSiteMapProvider" description="CMS provider for Global navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Global" EncodeOutput="true" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
< add name="CombinedNavSiteMapProvider" description="CMS provider for Combined navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Combined" EncodeOutput="true" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
< add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="true" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
< add name="CurrentNavSiteMapProviderNoEncode" description="CMS provider for Current navigation, no encoding of output" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="false" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
....
....
....
< /providers >
< /siteMap >
This is the piece of the web.config with the DynamicChildLimit property set to 0:
< siteMap defaultProvider="CurrentNavSiteMapProvider" enabled="true" >
< providers >
....
....
....
< add name="GlobalNavSiteMapProvider" description="CMS provider for Global navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Global" EncodeOutput="true" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
< add name="CombinedNavSiteMapProvider" description="CMS provider for Combined navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Combined" EncodeOutput="true" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
< add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="true" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
< add name="CurrentNavSiteMapProviderNoEncode" description="CMS provider for Current navigation, no encoding of output" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="false" IncludePages="PerWeb" IncludeHeadings="true" IncludeAuthoredLinks="true" DynamicChildLimit="0" / >
....
....
....
< /providers >
< /siteMap >
Friday, February 12, 2010
Access denied when copying file to GAC
I was trying to copy a dll to GAC on a Windows Server 2008 machine and kept getting "Access Denied" message.
After fighting with the message for a while and playing with some settings figured the solution. Turning off User Access Control solves the problem. Steps to turn off User Access Control are:
1. Go to Control Panel --> User Accounts
2. Click on "Turn User Account Control On or Off" link
3. Uncheck "Use User Account Control(UAC) to help protect your computer" and Click OK.
After fighting with the message for a while and playing with some settings figured the solution. Turning off User Access Control solves the problem. Steps to turn off User Access Control are:
1. Go to Control Panel --> User Accounts
2. Click on "Turn User Account Control On or Off" link
3. Uncheck "Use User Account Control(UAC) to help protect your computer" and Click OK.
Tuesday, March 31, 2009
Renaming the URL of a web application
Sometimes a company might want to change the URL of a sharepoint web application for branding or some other purpose. This change sounds a little challenging but it is not very complicated.
Following steps need to be followed:
1. In Central Administration, go to Alternate Access Mappings (AAM) under the Operations.
2. Select the Web Application from the Alternate Access Mapping Collection for which you want to change the URL.
3. Edit the public URL for this mapping collection to the new URL
Yes, thats it! Not really :-) ... any changes done in AAM do not get reflected in IIS. The host header for the web application need to be modified by opening the IIS manager. Here are the steps:
1. Open IIS Manager and go to the Web Site for which the URL is being changed.
2. Right-click and click on Properties.
3. Under the Wb Site tab, click on Advanced button next to the IP Address.
4. Change the host header to the new URL value.
5. The above steps need to be repeated for each server in the SharePoint web farm. :-(
Yes, That's it. The URL is changed. :-)
But wait, there are a few caveats:
1. Many times, the CEWP and image web parts have absolute links. SharePoint even changes relative links to absolute links. So, these links will still be pointing to the old URL. They will have to be updated. I wrote a small script to do it. Here is a snippet of the code:
mgr = oWeb.GetLimitedWebPartManager(page.Uri.ToString(), System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
parts = GetCEParts(mgr.WebParts);
foreach (ContentEditorWebPart wp in parts)
{
try
{
if (wp.Content.OuterXml.ToLower().Contains(urlToRemove.ToLower()))
{
if (page.ListItem.File.CheckOutStatus == SPFile.SPCheckOutStatus.None)
{
page.CheckOut();
}
swLog.WriteLine("Hard Coded path found in " + page.Uri);
XmlDocument doc = new XmlDocument();
string outerXML = wp.Content.OuterXml.Replace(" ", "");
outerXML = StringHelper.ReplaceText(outerXML, urlToRemove, urlReplace, StringHelper.CompareMethods.Text);
doc.LoadXml(outerXML);
wp.Content = doc.DocumentElement;
mgr.SaveChanges(wp);
page.Update();
page.CheckIn();
}
}
catch (Exception ex)
{
swErrorLog.WriteLine("Errors updating CEWP for: " + page.Uri.ToString() + ". Error was: " + ex.Message);
}
}
#region GetCEParts
private static ListGetCEParts(SPLimitedWebPartCollection list)
{
Listparts = new List ();
foreach (System.Web.UI.WebControls.WebParts.WebPart item in list)
{
if (item.GetType() == typeof(ContentEditorWebPart) item.GetType().BaseType == typeof(ContentEditorWebPart))
parts.Add((ContentEditorWebPart)item);
}
return parts;
}
#endregion
This code would need to be run for all pages having CEWPs. Code also needs to be run to update image URLs for image web parts.
2. Sometimes, you will start getting "Value does not fall within the expected range" when going to Page Settings for a page. Hopefully, you do not need to go to the Page Settings of a lot of pages as resolving this is a manual process and takes time! Here is a great blog to resolve this issue: http://www.bronios.com/index.php/2008/01/18/moss-page-setting-error-value-does-not-fall-within-the-expected-range/.
Labels:
aam,
branding,
host headers,
iis,
public url,
Sharepoint
Tuesday, February 17, 2009
"Request Timed Out" deleting site collection
Today, I tried to delete a site collection from Central Administration and I got the "Request timed out" error! The site still showed up on the site collection list in CA but did not show any details (URL, Title, Primary Administrator, Database) and it was no longer giving me the option to delete it. I thought the site collection was not deleted cleanly and I tried to use the stsadm to delete the site collection: stsadm -o deletesite -url http://[sitecollectionurl]. This gave the following error: The system cannot find the path specified. (Exception from HRESULT: 0x80070003).
After some digging, I realized that the site collection had got deleted but the content database was still keeping a reference to it. To resolve the problem, I removed the content database and then reattached it to the web application. Removing and reattaching the content database can be done either in Central Administration or by using the stsadm utility.
After some digging, I realized that the site collection had got deleted but the content database was still keeping a reference to it. To resolve the problem, I removed the content database and then reattached it to the web application. Removing and reattaching the content database can be done either in Central Administration or by using the stsadm utility.
Tuesday, January 20, 2009
The simple matter of adding the stsadm path to the Path Environment variable
All the time to use the stsadm command, you have to drill down to the bin folder in the Program Files directory a.k.a. to the c:\program files\common\microsoft shared\web server extensions\12\bin folder. To drill down to this folder every time you have to use the command is annoying at best!
To get around this, just add the stsadm path (c:\program files\common\microsoft shared\web server extensions\12\bin) to the Path environment variable. The steps to do this are:
To get around this, just add the stsadm path (c:\program files\common\microsoft shared\web server extensions\12\bin) to the Path environment variable. The steps to do this are:
- Right-click My Computer and go to properties
- Click the Advanced tab
- Click the Environment Variables button
- Under the System Variables list, look for the Path variable.
- Double-click the Path variable to edit it.
- Add ;C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN or add the shortcut ;%CommonProgramFiles%\Microsoft Shared\Web Server Extensions\12\BIN to the end of the Path variable
- Click OK three times and you are done! Now, if you go to the command prompt, you do not have to drill down to the stsadm path. You can use it directly since the path is saved in the Path environment variable.
Labels:
Environment Variables,
Path,
Sharepoint,
stsadm
Friday, August 15, 2008
Move the content index files on Index and Query servers
We initially created our content index for index and query servers on one drive and later had to move them to new disk drives on the servers. After a little looking around, I figured that this move can be achieved by using the stsadm command utility.
In our case we had a web farm with 3 front-end servers and 1 index server. Only one of the front-end server is being used as the query server.
Move the files for the index server
In our case we had a web farm with 3 front-end servers and 1 index server. Only one of the front-end server is being used as the query server.
Move the files for the index server
- Find the title of the SSP for which you want to move the content index. It is the name of the SSP and can be founf by going to Central Administration and looking under the Shared Services Providers
- Open the command prompt on the server and if the 12 hive/bin path is not in your PATH environment variable, navigate to it. It is usually C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin.
- Run the following command: stsadm -o editssp -title SharedServices1 -indexlocation e:\search. In my case, the new location was e:\search. The folder does not need to be created before hand. Executing the stsadm command creates it.
- Delete the old index location. The above command copies the files.
- If you are moving the index for multiple SSPs, repeat steps 1-4 for each additional SSP.
Move the index files for the Query server
- Logon to the query server and open the command prompt
- Navigate to the 12 hive/bin folder if the 12 hive/bin is not in the PATH environment variable.
- Run the following command to move the index: stsadm -o osearch -propagationlocation e:\search
Restart the Search Service for both the index and the query server. The search service can be restarted from Central Administration by going to the Operations tab and then "Services on Server".
Labels:
indexserver,
MOSS Search,
query server,
Sharepoint Search
Friday, August 8, 2008
User shows up in people picker after being deleted from Active Directory
If a user has ever accessed a sharepoint site or had been added to a sharepoint site, he/she will keep appearing in the people picker after the user has been deleted from the corresponding active directory because of termination/name change/???. To correct the people picker, follow these simple steps:
- Go to Site Setting -> People and Groups
- In "All People", filter on the user name that was deleted from AD.
- Select the user and choose Delete users from site collection under the Actions menu
This will remove the user from the people picker.
The New! document or listitem days
Ever wondered how to change the number of days to show the "New!" icon that appears for new documents and list items in a SharePoint site? There is a property days-to-show-new-icon that needs to be set using the stsadm command line.
To get the current value for a web application use:
stsadm -o setproperty -pn days-to-show-new-icon -url http://sharepointsite/
The default value for the property is 2
To set the value use:
stsadm -o setproperty -pn days-to-show-new-icon -pv 5 -url http://sharepointsite/
Now, the "New!" icon will appear for 5 days for all new documents and list items
To get the current value for a web application use:
stsadm -o setproperty -pn days-to-show-new-icon -url http://sharepointsite/
The default value for the property is 2
To set the value use:
stsadm -o setproperty -pn days-to-show-new-icon -pv 5 -url http://sharepointsite/
Now, the "New!" icon will appear for 5 days for all new documents and list items
Query servers "Configure share automatically" account
I was configuring a web front-end as a query server for our SharePoint farm. So, I was trying to start the Office SharePoint Search service on that WFE but kept getting the error: Failed to configure propagation share. After some trial and search, found that the account used to propagate the share needs to be part of the WSS_ADMIN_WPG group in addition to the local administrators group.
Wednesday, April 16, 2008
Moving the server that hosts Central Administration
In our company for MOSS installation, we created a webfarm with three servers and Central Administration (CA) site was hosted on one of them. However, we added a fourth server later and wanted to use the fourth server to host the CA and do other management activities.
I went ahead and ran the SharePoint product and technologies configuration wizard on the fourth server and configured it to host the CA website using Advanced Settings. But the link to SharePoint 3.0 Central Administration link still took me to the server where CA was hosted initially. I removed the CA site from the first server but still the SharePoint 3.0 Central Administration link continued to take me to the first server and the link failed as I had configured that machine not to host CA!
After a little research, I found that I needed to follow the following steps to accomplish my objective:
I went ahead and ran the SharePoint product and technologies configuration wizard on the fourth server and configured it to host the CA website using Advanced Settings. But the link to SharePoint 3.0 Central Administration link still took me to the server where CA was hosted initially. I removed the CA site from the first server but still the SharePoint 3.0 Central Administration link continued to take me to the first server and the link failed as I had configured that machine not to host CA!
After a little research, I found that I needed to follow the following steps to accomplish my objective:
- First remove CA from the initial server before adding another server to host the CA site. Run the SharePoint product and technologies configuration wizard. Click next until you see an Advanced Settings button. Select Do not use this machine to host the web site. At this point, no server will be hosting CA!
- Now, on the server you wanted to move the CA hosting, run the SharePoint product and technologies configuration wizard. Click next until you see an Advanced Settings button. Select Use this machine to host the web site and finish configuring.
This did the trick.
Please note that you may want to backup the web.config file for CA on the initial server specially if you had made any changes to it for custom authentication providers etc. You should replace the web.config file on the new CA hosting server after you have configured it to host CA.
Monday, June 11, 2007
Long URL names in SharePoint give the following message in Explorer View: "Explorer View requires Internet Explorer 5.0 or greater and Web Folders"
Recently, we had this problem where long URLs in SharePoint caused Explorer View in Document Library to give this unhelpful mesage: "Explorer View requires Internet Explorer 5.0 or greater and Web Folders". Explorer View was working if the URL was shorter than 256 characters. We did a lot of research and could not find a solution and had to start asking our users to give smaller names to the sites and document libraries so that the URL length did not exceed 256 characters. This was really frustrating and became unacceptable after a point of time. We finally found a solution which involves updating a registry entry on the user's machine. So, without any further adieu, here is the registry entry that needs to be updated: HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main -> FeatureControl -> KB325355_INCREASE_WEBFOLDER_MAXURLLENGTH_TO_260CHAR and add a new DWORD value 'iexplore.exe' and give it a value of 1. You can also save the below as a .reg file and ask the user to run it:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\KB325355_INCREASE_WEBFOLDER_MAXURLLENGTH_TO_260CHAR]"iexplore.exe"=dword:00000001
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\KB325355_INCREASE_WEBFOLDER_MAXURLLENGTH_TO_260CHAR]"iexplore.exe"=dword:00000001
Subscribe to:
Posts (Atom)

