|
-
November 19th, 2010, 12:07 PM
#1
[RESOLVED] Calling javascript function in ASP.NET produces UNWANTED directory listing...
I have an ASP.NET (c# codebehind) in which a simple <a> tag invokes a javascript function... Calling this function will produce an unwanted directory listing even if the javascript does absolutely nothing... Obviously it intended to do something, but I have boiled this down to the simplest possible code in an effort to figure out what is causing this problem and to provide an example demonstrating the problem for this thread...
How can I make this directory listing (or attempted directory listing) go away???
Here is the code that produces this problem:
Code:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="GN3.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>How do I make this directory listing go away...</title>
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function Preview()
{
// do absolutely nothing
}
</script>
</HEAD>
<body>
<a href="" onclick="Preview()">Click here for an UNWANTED directory listing...</a>
</body>
</HTML>
-
November 20th, 2010, 10:13 AM
#2
Re: Calling javascript function in ASP.NET produces UNWANTED directory listing...
I *think* you need to do something like this:
Code:
<a href="#" onclick="Preview(); return False;">
The Return False prevents the click from actually registering. The "#" keeps it from trying to navigate to a new page or anything.
-tg
-
November 21st, 2010, 06:46 PM
#3
Re: Calling javascript function in ASP.NET produces UNWANTED directory listing...
Thank You TechGnome!!! That worked very well!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|