Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Aug 26, 2011 @ 00:04
    Bjarne Fyrstenborg
    0

    Change filename of vCard

    Hi..

    I'm using the same method from Business Website Starter Pack to save a vCard.
    But I was wondering how to change the filename e.g. to nodeName, so they don't all have the same name?

    <msxml:script language="CSharp" implements-prefix="gecko">
    <msxml:assembly name="System.Web" />
    <msxml:using namespace="System.Web" />
     
    <![CDATA[
    public void changeOutPut(String ContentType, String FileName) {
            HttpContext.Current.Response.ContentType = ContentType;
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + FileName);
    }
    ]]>

    </msxml:script>
    .......
    <xsl:value-of select="gecko:changeOutPut('text/calendar','vCard.vcf')" />

    Bjarne

  • Rich Green 2246 posts 4006 karma points
    Aug 26, 2011 @ 00:09
    Rich Green
    1

    Hi,

    Something like this (not tested)

    <msxml:script language="CSharp" implements-prefix="gecko">
    <msxml:assembly name="System.Web" />
    <msxml:using namespace="System.Web" />
    <![CDATA[
    public void changeOutPut(String ContentType, String FileName) {
            HttpContext.Current.Response.ContentType = ContentType;
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + FileName + ".vcf");
    }
    ]]>
    </msxml:script>

    .......

    <xsl:value-of select="gecko:changeOutPut('text/calendar',@nodeName)" />

     

    RIch

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Aug 26, 2011 @ 00:11
    Chriztian Steinmeier
    1

    Hi Bjarne,

    You can just take the filename from wherever you have the info, e.g. the @nodeName of a Document or similar:

    <xsl:value-of select="gecko:changeOutPut('text/calendar', @nodeName)" />

    BTW: You should check out Doug's blogpost on moving <msxsl:script> blocks into the App_Code folder.

    /Chriztian

  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Aug 26, 2011 @ 00:32
    Bjarne Fyrstenborg
    0

    Thank you both...

    I needed to do this:

     

    <msxml:script language="CSharp" implements-prefix="gecko">
    <msxml:assembly name="System.Web" />
    <msxml:using namespace="System.Web" />
     
    <![CDATA[
    public void changeOutPut(String ContentType, String FileName) {
            HttpContext.Current.Response.ContentType = ContentType;
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + FileName + ".vcf");
    }
    ]]>

    </msxml:script>
    .......
    <xsl:value-of select="gecko:changeOutPut('text/calendar', $currentPage/@nodeName)" />

     

    If I hadn't the $currentPage with it was saved as vcf.ics .. 

    Bjarne

  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Aug 26, 2011 @ 00:38
    Bjarne Fyrstenborg
    0

    I'm using a child node as vCard, where there on the parent node: http://ak-security.dk/profil/steffen-agerskov.aspx  just is inserted a normal link and the child node is picked..

    is there something you can do, so the url looks like a vCard (.vcf) instead of the template/node (.aspx) ?

    Bjarne

  • Bjarne Fyrstenborg 1182 posts 3441 karma points MVP 4x c-trib
    Aug 27, 2011 @ 14:45
    Bjarne Fyrstenborg
    0

    I have a problem with getting æøå when downloading the vCard and opening it in Outlook og Windows Live Mail.
    I guess it's something about the missing utf-8 charset, so I tried to add it, but it doesn't seem to change anything:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
            version="1.0" 
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
            xmlns:msxml="urn:schemas-microsoft-com:xslt" 
            xmlns:gecko="urn:gecko-com:xslt"
            xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
            exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets gecko">
    <xsl:output method="text" omit-xml-declaration="yes"/>


    <msxml:script language="CSharp" implements-prefix="gecko">
    <msxml:assembly name="System.Web" />
    <msxml:using namespace="System.Web" />
     
    <![CDATA[
    public void changeOutPut(String ContentType, String FileName) {
            HttpContext.Current.Response.ContentType = ContentType;
            HttpContext.Current.Response.AddHeader("content-type", "text/x-vcard;charset=utf-8");
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + FileName + ".vcf");
    }
    ]]>

    </msxml:script>


    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:text>BEGIN:VCARD</xsl:text><xsl:text>&#xa;</xsl:text>
    <xsl:text>VERSION:2.1</xsl:text><xsl:text>&#xa;</xsl:text>
    <xsl:text>N:</xsl:text><xsl:value-of select="$currentPage/vcardLastName" /><xsl:text>;</xsl:text><xsl:value-of select="$currentPage/vcardFirstName" /><xsl:text>&#xa;</xsl:text>
    <xsl:text>FN:</xsl:text><xsl:value-of select="$currentPage/vcardFirstName" /><xsl:text</xsl:text><xsl:value-of select="$currentPage/vcardLastName" /><xsl:text>&#xa;</xsl:text>
    <xsl:text>TITLE:</xsl:text><xsl:value-of select="$currentPage/vcardTitle" /><xsl:text>&#xa;</xsl:text>
    <xsl:text>ADR;INTL;PARCEL;HOME:</xsl:text><xsl:text>;;</xsl:text><xsl:value-of select="$currentPage/vcardAddress" /><xsl:text>;</xsl:text><xsl:value-of select="$currentPage/vcardCity" /><xsl:text>;;</xsl:text><xsl:value-of select="$currentPage/vcardZipCode" /><xsl:text>;Danmark</xsl:text><xsl:text>&#xa;</xsl:text>
    <xsl:text>LABEL;HOME;ENCODING=QUOTED-PRINTABLE:</xsl:text><xsl:value-of select="$currentPage/vcardAddress" /><xsl:text>=0D=0A=</xsl:text><xsl:value-of select="$currentPage/vcardCity" /><xsl:text></xsl:text><xsl:value-of select="$currentPage/vcardZipCode" /><xsl:text>=0D=0A=Danmark</xsl:text><xsl:text>&#xa;</xsl:text>
    <xsl:text>TEL;CELL:</xsl:text><xsl:value-of select="$currentPage/vcardPhone" /><xsl:text>&#xa;</xsl:text>
    <xsl:text>EMAIL;INTERNET:</xsl:text><xsl:value-of select="$currentPage/vcardEmail" /><xsl:text>&#xa;</xsl:text>
    <xsl:text>ORG: AK-Security</xsl:text><xsl:text>&#xa;</xsl:text>
    <xsl:text>URL;WORK: http://www.ak-security.dk</xsl:text><xsl:text>&#xa;</xsl:text>
    <xsl:text>END:VCARD</xsl:text><xsl:text>&#xa;</xsl:text>
    <xsl:value-of select="gecko:changeOutPut('text/x-vcard', $currentPage/@nodeName)" />
    </xsl:template>

    </xsl:stylesheet>

    Related to this site http://softwareas.com/vcard-for-developers it should have the utf-8 charset, which I have added.. or is something wrong?

    When I open it up in e.g. Windows Live Mail I get Ã¦ instead of æ and Ã¸ instead of ø.

    Bjarne

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies