Showing posts with label ASP.Net with JavaScript. Show all posts
Showing posts with label ASP.Net with JavaScript. Show all posts

Tuesday, February 14, 2012

Display Browser information using JavaScript


This program will display your browser information
 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="javascript.aspx.cs" Inherits="javascript" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Google map using Java script</title>

<script language=javascript>
function show()
{

  document.write("Name "+navigator.appName+"<br>");
  document.write("Version "+navigator.appVersion  +"<br>");
  document.write("Codename " +navigator.appCodeName  +"<br>");
  document.write("Cookie enable"+navigator.cookieEnabled  +"<br>");
  document.write("Java Enable"+navigator.javaEnabled  +"<br>");
  document.write("Mime type"+navigator.mimeTypes  +"<br>");
  document.write("Platform"+navigator.platform  +"<br>");
  document.write("Plug ins"+navigator.plugins  +"<br>");
  document.write("System Language"+navigator.systemLanguage  +"<br>");
  document.write("User language"+navigator.userAgent  +"<br>");
  document.write("User Agent"+navigator.userAgent  +"<br>");

}


</script>

   
</head>
<body>
    <form id="form1">
    <div>
        <input id="Button1" type="button" value="Click me" onclick="show()" />
  
    </div>
    </form>
</body>
</html>

Java Script timer Example in ASP.Net


Timer is used to fire certain action after a certain time period



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="javascript.aspx.cs" Inherits="javascript" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
   
    <script language=javascript>

function timeMsg()
{
var t=setTimeout("alertMsg()",3000);
}
function alertMsg()
{
alert("Hello");
}        
 
    </script>
   
   
</head>
<body>
    <form id="form1">
    <div>
   
   
    <input id="Button1" type="button" value="Click me to display message" onclick="timeMsg()" />
  
    </div>
    </form>
</body>
</html>

Change HTML form content using JavaScript


This code is for Change form element value using JavaScript

Before change of form content

After Change of form Content  
 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="javascript.aspx.cs" Inherits="javascript" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
   
    <script language=javascript>
     function check()
     {
            
       document.getElementById("myp").innerHTML="Content has changed";
     
    }
    </script>
   
   
</head>
<body>
    <form id="form1">
    <div>
   
    <p id="myp">Click button to change me</p>
        <input id="Button1" type="button" value="button" onclick="check()" />
  
    </div>
    </form>
</body>
</html>

Form Validation using JavaScript in ASP.Net


Program of form validation using JavaScript in ASP.Net



Write below code to validate your form using JavaScript

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="javascript.aspx.cs" Inherits="javascript" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
   
    <script language=javascript>
     function check()
     {
       // alert("Hello");
      
       var name=document.getElementById("name").value;
       var age=document.getElementById("age").value;
       if(name=="" || age=="")
       {
         alert("Enter name and age");
       }
      
     }
    </script>
   
   
</head>
<body>
    <form id="form1">
    <div>
    Enter name:-<input id="name" type="text" /><br />
    Enter age:- <input id="age" type="text" />
    <input id="Submit1" type="submit" value="Save it" onclick="check()" />
  
    </div>
    </form>
</body>
</html>