You must Sign In to post a response.
  • Category: HTML

    Issue on string variable html encoding

    Hi Friends,

    There is a simple scenario where I am facing some html encoding issue. I have a class file where I am assigning local string variable value with html tagging (This string variable contains the comma separated multiple values.).

    workitemList = workitemList + HttpUtility.HtmlEncode("<a target=\"_new\" href=\"" + buildDetail.BuildServer.TeamProjectCollection.Name.ToString() + "/" + buildDetail.TeamProject + "/_workitems#id=" + workitem.Id + "&_a=edit \>" + workitem.Id + "</a>") + ", ";


    And here we are using this string variable in our .xslt file for email notification html format.
    <tr>
    <td>5</td>
    <td>Associated WorkItem(s)</td>
    <td>
    <xsl:if test="EmailParameters:get_BuildStatus()='Succeeded'">
    <xsl:value-of select="EmailParameters:get_BuildWorkItemlists()" />
    </xsl:if>
    </td>
    </tr>


    Now the issue is coming On email notification, this variable value is displaying with all html coding.
    5 Associated WorkItem(s) <a target="_new" href="http://localhost:8080/tfs12/tc2012/Lg_Test/_workitems#id=68&_a=edit ">68</a>, <a target="_new" href="http://localhost:8080/tfs12/tc2012/Lg_Test/_workitems#id=69&_a=edit ">69</a>

    Please help, I tried many thing to get it done and no luck.
    i tried
    HttpUtility.HtmlEncode
    Uri.EscapeDataString
    using html decoded < and >
    but nothing done.
  • #754040
    Hai Abhijit,
    You can encode your string variable by using the HtmlEncode method as below and then use it:

    workitemList = workitemList + HttpUtility.HtmlEncode("<a target=\"_new\" href=\"" + buildDetail.BuildServer.TeamProjectCollection.Name.ToString() + "/" + buildDetail.TeamProject + "/_workitems#id=" + workitem.Id + "&_a=edit \>" + workitem.Id + "</a>") + ", ";
    HttpUtility.HtmlEncode(workitemList );

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #754085
    Thanks for the response Pawan.
    I am sorry it didn't work for me :(

  • #754147
    Have you set the Email body type as HTML, if it is not set as HTML it will display as string.

    Please check the email type.

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM


  • Sign In to post your comments