Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript and XML/XSTL issue in ASP.NET

    Hey all,

    I am having an issue with XML/XSLT and JavaScript in my ASP.NET page that I am creating. I first want to apologize if i placed this in the wrong category. Since there were three different entities here i wasn't 100% sure where to place it.

    Here is the background on the issue:

    I have a XML tag that is located in multiple places and multiple documents that has a structure of:
    <LINK ID="para0001">LINK TEXT</LINK>
    This tag essentially will hold a link to a related pice of material.

    I also have a seperate XSLT sheet that I created that (using C#) I convert the XML to HTML on the fly. The section of the XSLT sheet that does this for me for the link is:
    <xsl:template name="link" match="LINK">
    <a href="noJSP.html">
    <xsl:attribute name="onClick">
    <xsl:text>linkRedirect('</xsl:text>
    <xsl:value-of select="@ID" />
    <xsl:text>'); return false;</xsl:text>
    </xsl:attribute>
    <xsl:call-template name="text" />
    </a>
    </xsl:template>

    Now when this XML page is created as an HTML page, the conversion looks like it works perfectly fine, showing the link in HTML as:
    <a href="noJSP.html" onClick="linkRedirect('para0001'); return false;">LINK TEXT</a>

    Now, here is the problem:
    To my understanding, when a link has a onClick value that relates to a JavaScript function it is supposed to execute that function before doing anything else (given the only other thing on the link is the href value). However, when i click the link, my JavaScript function is not even so much as entered. I know this because the first line in the JavaScript I have is
    alert("I am in");
    and it never pops up the alert window. It just attempts to redirect to the html page noJSP.html.

    Now, JavaScript IS enabled for the browser. I know that is a common issue that some people have had with similaur situations, and that is the first thing i checked. With that in mind, doe sanyone have any idea or suggestion as to why the link is not recognizing the JavaScript I have written out to use? Below is the larger sample of the ASP.NET page I created to use as a template. I appreciate any help you all can offer.

    <html>
    <head>
    <script language="javascript" type="text/javascript">
    function linkRedirect(location){
    alert("I am in");
    }
    </script>
    </head>
    <body>
    <form id="form1" runat="server">
    <span>
    <asp:Label runat="server" ID="document" />
    </span>
    </form>
    </body>
    </html>

    The ASP Label holds the HTML that is returned from my C# code. That I know works so I am not gonna waste any more space adding useless code that you all don't need.

    I look forward to any responses you all might come up with. I have tried everything I can think of, and am at a loss now as to why this doesn't work.

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Javascript errors elsewhere on the page would cause this behavior.
    Got a link to the live page?
    Otherwise, check error console (FF) or enable error messages (IE).

    This should be in either client side javascript forum or ASP.NET forum.
    This forum is for server-side Java/JSP (Sun, BEA, etc) which has nothing at all to do with client-side javascript, despite the name.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    Regular Coder Aradon's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    734
    Thanks
    0
    Thanked 20 Times in 19 Posts
    Since this is built with ASP.NET and revolves around a redirect problem inside of it I think it's most appropriate there.
    "To iterate is human, to recurse divine." -L. Peter Deutsch


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •