Question

Today, I had one one of the stragest problems. I have alist with a custom action that opens a popup. It works in englsh and dutch, but in french the popup never opens.

The thing is that in french the resource files says: Look the single quote

<data name="Message_GenerateSponsoringAgreement_SUCCESS" xml:space="preserve">
    <value>Création de l'accord de sponsoring terminée avec succes.</value>
  </data>

The custom action is as follows:Note that in javascript you pass variables with single quote. I tried replacing single quote with:

&#39;

and it didnt work. I tried replacing it with . and its not shown on the custom action

<UrlAction Url="javascript:function process(){var site='{SiteUrl}';OpenPopUpPageWithTitle(site+'/_layouts/spnl.sponsoring/GenerateSponsoringAgreement.aspx?ListID={ListId}&amp;ID={ItemId}&amp;Source=' + window.location, RefreshOnDialogClose, 400, 200,'$Resources:SPNLSponsoring,CustomAction_GenerateSponsoringAgreement_Title;');}; process();" />
Était-ce utile?

La solution

In C# you have the System.Web.HttpUtility.JavaScriptStringEncode() call available that will prepend single quotes with a backslash.

http://msdn.microsoft.com/en-us/library/system.web.httputility.javascriptstringencode.aspx

From the URL above:

This method encodes strings. For instance, single quotation marks and double quotation marks are included as \' and \" in the encoded string.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top