473,226 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

XML/XSLT and JavaScript issue

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:
[html] <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>[/html]

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]<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>[/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.
Mar 16 '07 #1
6 2544
dorinbogdan
839 Expert 512MB
Welcome to TheScripts TSDN....

Please post also the HTML code from client's page.
(open the page in browser, right-click / View Source)
Mar 16 '07 #2
The Client source looks like:

[HTML]<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
function linkRedirect(location){
alert("I am in");
}
</script>
</head>
<body>
<form name=form1" method="post" action="linkpage.aspx">
<span id="document">
<a href="noJSP.html" onClick="linkRedirect('para0001'); return false;">Click Me to go to the other page</a>
</span>
</body>
</html>[/HTML]

para0001 is a paragraph from a different page. The JavaScript in conjunction with my CodeBehind from the ASP.NET page should rediredt it. I have tested the code behind and that works fine, it is jus tthe fact that it doesnt want to enter the JavaScript function that is causing all of the problems.

Thanks for the help.
Mar 16 '07 #3
dorinbogdan
839 Expert 512MB
Also, remove the "return false" statement inside of onclick event (after linkRedirect('para0001') call), if you want to continue the href execution.
Mar 16 '07 #4
Thanks, yea i know that. I don't want to continue the href call unless the browser doesn't have JavaScript enabled.
Mar 16 '07 #5
dorinbogdan
839 Expert 512MB
I tested the html code (as appear on client side) and works on my station.
I always see the alert message, and the href is executed just depending on the return value.
Mar 16 '07 #6
dorinbogdan
839 Expert 512MB
Hi,
Did you succeed to solve the problem ?
If yes, please let me know, in order to close the thread.
Thanks,
Dorin.
Mar 21 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
7
by: RC | last post by:
First, let me say I couldn't find a group discuss XML/XSLT. So I only choose the closest groups to post this message. Here is part of my *.xsl file <xsl:stylesheet...
6
by: RC | last post by:
Hello World, I am try do call a JavaScript function from XSLT, but I got function not avaible error. See "????" below. Would someone out there tell me how? Thank Q! <xsl:stylesheet...
6
by: Jain, Pranay Kumar | last post by:
Hi All, We have created a simple application that takes a dataset and generates the data in Excel schema format. It uses an xslt file to do the transformation for excel 2002 and so on. We are...
0
by: Christopher M. Lauer | last post by:
I have done my best to answer this question but can not find the proper set of commands. I would like to transform an xml file (in code behind) and display its output in a specific html tag,...
4
by: Gauthier | last post by:
Hi, I've a simple issue with the use of extension objects. I'm trying to call a text formating method from an object that I add to my arguments collection, this method take an input string and...
4
by: elsigh | last post by:
I'm wondering if anyone has any ideas about a way to quickly convert an HTML DOM Node into an XML Document. The goal is that I want to perform XSLT on the Node, which is coded correctly as XHTML....
6
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a...
3
by: RC | last post by:
Let's say: if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { // Now I got an XML object here var xmlDocument = XMLHttpRequestObject.responseXML; // next I have...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.