Solved

Javascript and ASP.NET

Posted on 2003-11-06
4
990 Views
Last Modified: 2013-11-19
I am trying to integrate some javascript code into a web user control. Unfortuantely, the page keeps throwing up errors when I try to view it.

I tried inserting directly into the formatting code (using <SCRIPT> tags), but to no avail. Then I tried using Response.Write. Still receiving errors. The javascript itself has no errors, and this is merely a test to get it in. Anybody have an idea what I am doing wrong?

Ryan
0
Comment
Question by:rossryan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Expert Comment

by:kingsfan76
ID: 9697387
0
 
LVL 4

Accepted Solution

by:
meet_zorrer earned 500 total points
ID: 9706211
Hi !
you can register you javascript script block in an ASPX.NET page using:

Dim sJavaScript As String = "<script language='javascript' src='OpenWindow.js'></script>"

Page.RegisterClientScriptBlock("myJavaScript", sJavaScript)

Regards,
Meet
0
 

Author Comment

by:rossryan
ID: 9724047
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title></title>
            <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
            <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
            <LINK href="1-800-FLOWERS_COM_files/styles.css" type=text/css rel=STYLESHEET>
            <STYLE type=text/css>A.menuLink:link {
      TEXT-DECORATION: none
}
A.menuLink:hover {
      FONT-WEIGHT: bold; COLOR: #333333; TEXT-DECORATION: none
}
A.menuLink:active {
      COLOR: #333333; TEXT-DECORATION: none
}
A.menuLink:visited {
      TEXT-DECORATION: none
}
        </STYLE>
            <SCRIPT LANGUAGE="JavaScript">
var xPos,yPos;
xPos = 0;
yPos = 0;
var isNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);

    function showObject(object)
    {
            var lft,tp;
            w1 = document.images["img1"].width;
            w2 = 345;
            lft = xPos - (w2-w1);
            tp = yPos;
            object.left = lft + 11;
            object.top = tp - 25;
            object.borderColor = 'green';
        object.visibility = VISIBLE;
    }

   function hideObject(object)
    {
        object.visibility = HIDDEN;
    }

            </SCRIPT>
            
      </head>
      <body>
            <table>
                  <tr valign="top">
                        <td class="descriptText">
                              <div id="toEnlarge" class="toEnlarge">
                                    <a href="#" onMouseover="showObject(desc10)">
                                          <img name="img1" src="http://shop.vixenhill.com/Images/GazeboImages/QA12ACopper.jpg"
                                          width="120" height="120" border="0" alt="" align="right" hspace="0" vspace="0">
                                    </a>
                              </div>
                        </td>
                  </tr>      
            </table>
            <div id="desc10" name="desc10" CLASS="IsEnlarge" ALIGN=RIGHT>
                  <a href="#" onMouseOut="hideObject(desc10)">
            <img name="bigimage" CLASS="col0" border="4" src="http://shop.vixenhill.com/Images/GazeboImages/QA12ACopper.jpg"
                               alt="" hspace="0" vspace="0" width="300" height="360"> </a>
            </div>
            <SCRIPT LANGUAGE="JavaScript">
    var isNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
    var HIDDEN = (isNS) ? 'hide' : 'hidden';
    var VISIBLE = (isNS) ? 'show' : 'visible';
    var toEnlarge = (isNS) ? document.toEnlarge : document.all.toEnlarge.style;
    var desc10 = (isNS) ? document.desc10 : document.all.desc10.style;          
            </SCRIPT>
      </body>
</html>

Hmm. Perhaps I should rephrase. I need the above code (Javascript section) to play nice with a repeater. Basically, I want the ASP code to grab the Javascript code, insert the image (via Container.Dataitem), and when the mous moves over it, I want to to enlarge from from a predefined size to the images max.

 If I have missed anything, or if you need more information, please ask.

Thanks,
Ryan
0
 

Author Comment

by:rossryan
ID: 9884288
Rewriting the script and throwing it in a .js file worked like a charm.

Thanks,

Ryan
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Field that has HTML displays the code instead of the text in html 16 122
Problem to open text file 11 144
Randomize in Owl Carousel v1.3.2 6 132
Grunt script for Build Process 1 90
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question