Archive for WebPart

SharePoint: You cannot deploy this solution on this type of server computer as it is configured. This solution must be installed on a server of type: front-end Web server

Scenario:

We tried to deploy wsp via Visual Studio 2013 on our development server, deployment stopped with following error:

You cannot deploy this solution on this type of server computer as it is configured. This solution must be installed on a server of type: front-end Web server

We tried using PowerShell, but it hangs at “Deploying”. Tried solution like adding “loopback check” but it didn’t work in case of wsp deployment.

Resolution:

Finally, disconnecting and connecting configuration database did the trick but at the cost of creating new CA.

Steps are:

  1. Run cmdlet to disconnect configuration database
  • Disconnect-SPConfigurationDatabase –Confirm:$false
  1. Close PowerShell window and open new PowerShell window
  2. Run cmdlet to connect configuration
  • $passphrase = ConvertTo-SecureString -String “sharepoint@2013” -asPlainText -Force
  • Connect-SPConfigurationDatabase -DatabaseServer SQLServerInstanceName -DatabaseName SharePoint_Config -Passphrase $passphrase
  • Start-Service SPTimerv4
  1. Run SharePoint Configuration wizard and created new central administration.

We were able to deploy solutions via Visual Studio but newly created Central Administration need to deploy every wsp.


Leave a Comment

SharePoint:InputFormTextBox: Validation Issue after postback

Scenario:

We have placed a “SharePoint:InputFormTextBox” text control on our webpart and wanted to make it a “Required Field”. We added an ASP “RequiredFieldValidator” which works fine when we click submit.

We have other controls on the form as well. If an event is occurred and any other controls postback, then, the validation on “SharePoint:InputFormTextBox” fails to work if we try to submit.

Resolution:

We look into the issue and tried to resolve by adding implementing different solutions but nothing was working. In the end, found a reply on MS SharePoint forum that was buried in other replies. Suggested setting the initial property of “RequiredFieldValidator”.

Turned out the when webpart postback, somehow, “<DIV></DIV>” is added in “SharePoint:InputFormTextBox”. You can check it by editing the control “SharePoint:InputFormTextBox” after postback from some other control.

We set

RequiredFieldValidator3.InitialValue = “<DIV></DIV>”

in every control server-side code that postback.

Source: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopmentlegacy/thread/e9fbbd43-bef9-48fc-9a9f-0011514798e7/ Look at the last reply by “cschoenfeldt“.

Leave a Comment

SharePoint: Reduce space b/w webparts

Scenario:

We need to reduce space b/w webparts

Resolution:

SharePoint add a div after webaprt with class “ms-PartSpacingVertical” which has margin-top property set to 12px. Add class with the same name and make margin-top zero. In our scenario, webparts were added inside div with id “middle”, so we added following class

#middle .ms-PartSpacingVertical{

    margin-top: 0px !important;

}

Leave a Comment

SharePoint: Incompatible Web Part markup detected. Use *.dwp Web Part XML instead of *.webpart Web Part XML

Scenario:

We deployed a webpart and when tried it to add it on the page, following error occurred:

Incompatible Web Part markup detected. Use *.dwp Web Part XML instead of *.webpart Web Part XML.

Resolution:

This error occurs when you have not inherited your class from “System.Web.UI.WebControls.WebParts.WebPart”. We have inheritated our class from “Microsoft.Office.Server.WebAnalytics.Reporting.WhatsPopularWebPart” class as we were customizing OOTB “WhatsPopularWebPart”. The resolution is to create your own “.dwp” file. Copy pate following XML, make appropriate changes and save it with “.dwp” extension.

<?xml version=”1.0″?>

<WebPart xmlns=”http://schemas.microsoft.com/WebPart/v2″&gt;

<Assembly>[AssemblyName],Version=[X.X.X.X], Culture=[XXXXX],PublicKeyToken=[XXXXXXXX]</Assembly>

<TypeName>WebPartNamespace.WebPartClassName</TypeName>

<Title>WebPartTitle</Title>

<Description>WebPartDescription</Description>

</WebPart>

One quick way is to open “.webpart” file and replace values.

Second step is to go to 14 hives or 12 hives [C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES], found the feature folder. Delete “.webpart” file and paste “.dwp” file. Repeat the same process in the SharePoint installation. Go to Site Collection Settings-> Web parts (under Galleries). Delete “.webpart” file and upload “.dwp” file.

Source:

http://blog.sharepointdevelopment.nl/post/Unable-to-add-selected-Web-Part-Incompatible-Web-Part-markup-detected.aspx

Comments (2)

SharePoint 2010: Display titles instead of URL’s in WhatsPopularWebPart

Scenario:

We need to display / render titles instead of the URL’s in “WhatsPopularWebPart”.

Resolution:

Google the problem and found following blog with an excellent idea how to accomplish above:

http://rolandoldengarm.wordpress.com/2011/04/08/whatspopularwebpart-render-titles-instead-of-urls/

As per “Roland Oldengarm” already stated that we “to created a webpart derived from WhatsPopularWebPart and implemented also ICallbackEventHandler”. Started working on it and found some implementation issues. First, we need to change the Regex and second, we need to change the code.


public class TestWebPart :

Microsoft.Office.Server.WebAnalytics.Reporting.WhatsPopularWebPart, ICallbackEventHandler

{

private const string ItemRegEx = @”<span dir=’ltr’>(?<url>[^<]*)</span>”;

private static string ReplaceUrlsWithTitles(string html)

{

if (Regex.IsMatch(html, ItemRegEx))

{

html = Regex.Replace(html, ItemRegEx, delegate(Match match)

{

var url = match.Groups[“url”].Value;

string title = url;

using (SPSite spSite = new SPSite(SPContext.Current.Site.Url))

{

using (SPWeb spWeb = spSite.OpenWeb(title))

{

try

{

var item = spWeb.GetListItem(title);

if (item != null)

{

title = item.Title;

}

}

catch (Exception e) { }

}

}

return
“<span>” + title + “</span>”;

},RegexOptions.IgnoreCase);

}

return html;

}

string ICallbackEventHandler.GetCallbackResult()

{

return ReplaceUrlsWithTitles(base.GetCallbackResult());

}

void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)

{

base.RaiseCallbackEvent(eventArgument);

}

}

Comments (33)

SPWebPartManager.SaveChanges – Parameters

We need to update or change properties of a web part on different pages. For this, wrote a power shell script that updates or change the properties of the webpart. When we try to save the change properties using SPWebPartManager.SaveChanges method, our script through exception

As per MS, SPWebPartManager.SaveChanges takes storageKey as valid parameter but our script through exception every time we run it with the storageKey as parameter.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.spwebpartmanager.savechanges.aspx

Google it and tried to pass webpart as parameter. Worked like a charm.

Still looking at the documentation and wondering………………….

Leave a Comment

SharePoint Designer 2010: Change Chrome Type property of Web Part in SharePoint Designer

Scenario:

We added web parts in a page layout using SharePoint Designer 2010. Requirement was to set Chrome Type property to “none” of the web part in page layout.

Resolution:

This can be done either in design view or code view of the page layout.

Design View:

Click on the “Design” of the page layout, select the web part. Go to “Web Parts Tools” section of the Ribbon, select “Format” tab and in appearance section you will find “Chrome Type”.

Code View:

If you are adding out of the box web part, you need to add following tag:

<FrameType>Value</FrameType>

Following table provide Chrome Style and values:

FrameType (Chrome Style)

Value

Default

Default

None

None

Title and Border

Standard

Title Only

TitleBarOnly

Border Only

BorderOnly

 

If you are adding customized web part, add following tag:

ChromeType=”None”

Leave a Comment

Older Posts »