Pergunta

I would like to know the best way to encode parameters (with a space or other unsafe characters) when passing these to another List.

With ddwrt:UrlEncode ?

<xsl:variable name="MyURL"
  select="concat('../../Lists/MyList/MyView.aspx?MyID=',@ID,'&amp;MyName=',ddwrt:UrlEncode(string(@Title)))" />

The question is how to read this value on the page ? This one fails :

<xsl:value-of select="$MyName" />
Foi útil?

Solução

I found out that there's no need to encode a parameter using ddwrt:UrlEncode.

So the code on the first page becomes:

1) Building the URL

<xsl:variable name="MyURL" select="concat('../../Lists/MyList/MyView.aspx?ID=',@ID,'&amp;MyName=', @Title)" />

2) Creating a hyperlink

<a onclick="GoToLink(this); return false;" target="_self">
  <xsl:attribute name="href">
    <xsl:value-of select="$MyURL" />
  </xsl:attribute>
  Click My Link
</a>

Code on second page is just:

<ParameterBindings>
 ...
    <ParameterBinding Name="MyName" Location="QueryString(MyName)" DefaultValue="-"/>
</ParameterBindings>

<xsl:stylesheet />
  <xsl:param name="MyName" />
...

MyName : '<xsl:value-of select="$MyName" />'

Outras dicas

You'll definitely need to URLEncode values passed in URLs somehow. In plain .Net code this is done using HttpUtility.UrlEncode(), but if the ddwrt namespace has an XSL function which does this (as you appear to have found), I would have thought that should be fine too.

Can you verify this function works, perhaps by calling it in a different context?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top