Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

Learn more about...

AspDotNetStorefront
DotFeed

Embedding Javascript link in XMLPackage

I am trying to embedd a javascript popup to another page and want to pass a parameter of a product id that is generated in the XMLPackage.  Please see the code below that I am trying to get to work.  Would it be possible or how would it be possible to accomplish this?


            <xsl:template name="CustFileUpload">
                <div>
                    <a href="javascript:window.open('AjaxFileUpload.aspx?pid=<xsl:value-of select="ProductID"/>','Customer File Upload','width=500,height=300')">
                        <strong class="general_store_text" style="font-weight:bold">File Upload</strong>
                    </a>
                </div>
            </xsl:template>

 

asked Dec 30, 2013 in MultiStore by cshetler (225 points)

3 Answers

0 votes
Hi Christopher,

That looks like a good start. Have a look at the page source when loading in a browser, to ensure that the javascript is populating correctly along with the product id.

Sincerely,
Robert
answered Dec 30, 2013 by Robert (3,440 points)

Hi.  Thanks for replying.

I thought the code looked fine and don't see why it won't work.  I am getting an error below:

 

Page URL:/store/p-3414-acrylic-block-with-diamond-cut-accent-blue-reflective-base.aspx 
Source:AspDotNetStorefrontCore 
Message:Error in XmlPackage(.Load), Package=[product.variantproductattribconfigurator.xml.config], Msg=[Exception='<', hexadecimal value 0x3C, is an invalid attribute character. Line 736, position 78.<br/>] 
Stack Trace: 
at AspDotNetStorefrontCore.XmlPackage2..ctor(String PackageName, Customer cust, Int32 SkinID, String UserQuery, String AdditionalRuntimeParms, String OnlyRunNamedQuery, Boolean UseExtensions) 
at AspDotNetStorefront.showproduct.Page_Load(Object sender, EventArgs e) 
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) 
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) 
at System.Web.UI.Control.OnLoad(EventArgs e) 
at System.Web.UI.Control.LoadRecursive() 
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

 

That could be due to the single quotes. Try concatenating the product id onto the end.

For example:

'AjaxFileUpload.aspx?pid=' + <xsl:value-of select="ProductID"/>
HI.

Javascript concatenating didn't seem to work.  Also I am still getting the same error on the '<' character.
0 votes

Try changing your code to this:

 

<a href="javascript:window.open('AjaxFileUpload.aspx?pid={ProductID}','Customer File Upload','width=500,height=300')">
     <strong class="general_store_text" style="font-weight:bold">File Upload</strong>
</a>

This gets around the need to embed < within a quoted string which the XSLT processor complains about.

Adam

answered Jan 6, 2014 by Webopius (650 points)
Link is displaying '{ProductID}' as literal.
Hi, it looks like you might have solved it now but the above code works within a test XML package that I set up on 9.3.  Check that the quotes match the example above.
0 votes

I've found another XMLPackage that generated a link in a similar way and got it to work.  Below is my solution:

 

            <xsl:template name="CustFileUpload">
                <script type="text/javascript" language="javascript">
                    <![CDATA[
                    function FileUpload(ProductID,VariantID)
                    {
                        window.open('AjaxFileUpload.aspx?pid=' + ProductID + '&vid=' + VariantID, 'Customer File Upload', 'width=500,height=300');
                    }
                ]]>
                </script>            
                <div style="padding-top:10px;padding-bottom:10px;">
                    <a>
                        <xsl:attribute name="href">javascript:FileUpload(<xsl:value-of select="ProductID" />, <xsl:value-of select="VariantID" />);</xsl:attribute>
                        <strong class="general_store_text" style="font-weight:bold">File Upload</strong>
                    </a>
                </div>
            </xsl:template>

 

answered Jan 6, 2014 by cshetler (225 points)
...