Knowledge Walls
Gopal Rao
Mumbai, Maharashtra, India
Passcode:
How to use javascript in asp net with example
5607 Views
Introduction 
In asp.net java script/Jquey can write in two ways.
  1. Can write scripts seperately in specific file and refer to the required pages.
  2. Can write inside the head tag.
Syntax for 1st way
<head>
<script type="text/javascript" src="javaScriptFilePath" ></script>
</head>
Example
<head>
<script type="text/javascript" src="/javascript/jquery-1.7.2.min.js"></script>
</head>
Second method Syntax
<head>
<script type="text/javascript" >
            /*java script function*/
       </script>
</head>
Example
<head>
<script type="text/javascript" >
           function do_highlight(ele) {
               document.getElementById(ele.id).style.color = "black";
               if (ele.id.indexOf("UserName") != -1 && document.getElementById(ele.id).value == "Username") {
                   document.getElementById(ele.id).value = "";
               }
               if (ele.id.indexOf("PassLog") != -1 && document.getElementById(ele.id).value == "Password") {
                   document.getElementById(ele.id).value = "";
               }
           }
       </script>
</head>
Best Lessons of "Asp.net/Ado.net/C#.net(Dotnet)"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details