Sie sind auf Seite 1von 14

1) ASP.NET Web application using VB.

NET to display a report of Client IP address, Browser

Default.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb"


Inherits="practical_1._Default" %>

<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="IP address"></asp:Label>
<asp:Label ID="Label10" runat="server" Text="Label"></asp:Label>

</div>
<asp:Label ID="Label2" runat="server" Text="Server Port Number"></asp:Label>
<asp:Label ID="Label11" runat="server" Text="Label"></asp:Label>
<p>
<asp:Label ID="Label3" runat="server" Text="Server Software"></asp:Label>
<asp:Label ID="Label12" runat="server" Text="Label"></asp:Label>
</p>
<asp:Label ID="Label4" runat="server" Text="Local address"></asp:Label>
<asp:Label ID="Label13" runat="server" Text="Label"></asp:Label>
<p>
<asp:Label ID="Label5" runat="server" Text="Remote Host"></asp:Label>
<asp:Label ID="Label14" runat="server" Text="Label"></asp:Label>
</p>
<asp:Label ID="Label6" runat="server" Text="Server Name"></asp:Label>
<asp:Label ID="Label15" runat="server" Text="Label"></asp:Label>
<p>
<asp:Label ID="Label7" runat="server" Text="Path Information"></asp:Label>
<asp:Label ID="Label16" runat="server" Text="Label"></asp:Label>
</p>
<asp:Label ID="Label8" runat="server" Text="Browser"></asp:Label>
<asp:Label ID="Label17" runat="server" Text="Label"></asp:Label>
<p>
<asp:Label ID="Label9" runat="server" Text="Browser Version"></asp:Label>
<asp:Label ID="Label18" runat="server" Text="Label"></asp:Label>
</p>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
Default.aspx.vb

Public Class _Default


Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Label10.Text = Request.ServerVariables("Remote_host")
Label11.Text = Request.ServerVariables("server_port")
Label12.Text = Request.ServerVariables("script_name")
Label13.Text = Request.ServerVariables("http_user_agent")
Label14.Text = Request.ServerVariables("server_name")
Label15.Text = Request.ServerVariables("server_protocol")
Label16.Text = Request.ServerVariables("path_info")
Label17.Text = Request.Browser.Browser
Label18.Text = Request.Browser.Version
End Sub
End Class
2) ASP.NET Web application using VB.NET to display Server Side Time among with client-side
script to display Client Side Time.

Default.aspx.vb

Public Class WebForm1


Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


Response.Write("<h1>Server Side Date Time</h1>")
Response.Write("<br>Server Side Dae is:-" & Date.Now.Date)
Response.Write("<br>Server Side Time is:-" & Now)
Response.Write("<br>Server Side Month is:-" & MonthName(Now.Month))
Response.Write("<br>Server Side WeekDayName is:-" & WeekdayName(Now.DayOfWeek))
Response.Write("<h1> Client Side Date & Time</h1>")
Response.Write("<br> Client Side Date & Time is:-<script>var d; d=new
Date();document.write(d);</script>")
End Sub
End Class
3) ASP.NET Web application using VB.NET to calculate the number of days a Person has lived on
basis of the date of Birth.

Default.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb"
Inherits="pract11._Default" %>
<!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></title></head><body>
<form id="form1" runat="server">
<div> Date_of_Birth:-<asp:Label ID="Label1" runat="server"></asp:Label> </div>
<p><asp:Label ID="Label6" runat="server" Text="Today date is :-"></asp:Label>
<asp:Label ID="Label2" runat="server"></asp:Label>
</p><p><asp:Label ID="Label7" runat="server" Text="Person Lived days are :-"></asp:Label>
<asp:Label ID="Label3" runat="server"></asp:Label>
</p><p><asp:Label ID="Label4" runat="server"
Text="-----------To Calculate the Number of Person Lived ---------"></asp:Label>
</p> <p>
<asp:Label ID="Label5" runat="server" Text="Enter Birth Date :-"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p> <p>
<asp:Button ID="Button1" runat="server" Text="Button" />
</p></form></body></html>

Default.aspx.vb

Public Class _Default


Inherits System.Web.UI.Page
Public Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim date1 As Date
Label1.Text = TextBox1.Text
Label2.Text = Date.Now.Date
date1 = Convert.ToDateTime(Textbox1.Text)
Label3.Text = DateDiff(DateInterval.Day, Date1, Now.Date)
End Sub
End Class
4) JAVASCRIPT PROGRAM TO VALIDATE PINCODE & AMOUNT.

PINCODEAMT.HTML
<html><head>
<title>Validation of Pincode and salary</title>
<script language="Javascript">

function PinSal()
{
var a,b,alen,x,y,dp;
a=f1.t1.value;
b=f1.t2.value;
alen=a.length;
dp=b.indexOf(".");
x=0;y=0;

if(alen<6 || alen>10)
{
alert("Pincode should be Min 6 and Max 10 in digits");
f1.t1.value="";
f1.t1.focus();
x++;
}
if(isNaN(a))
{
alert("Pincode should be in digits");
f1.t1.value="";
f1.t1.focus();
x++;
}
if(isNaN(b) || b<100)
{
alert("Plz enter proper salary and it has to be greater than 100");
f1.t2.value="";
f1.t2.focus();
y++;
}
if(dp>=0 && dp<b.length-3)
{
alert("Salary value is invalid !!! Plz Re-enter");
f1.t2.value="";
f1.t2.focus();
y++;
}
if(x<1 && y<1)
{
alert("Both Acceptable");
f1.t1.value="";
f1.t1.focus();
f1.t2.value="";
f1.t2.focus();
}
}
</script>
</head>

<body bgcolor="violet">
<h1>Validation of Pincode and Salary</h1>
<hr><br><br>
<form name="f1">
<b>Enter Pincode:</b><input type="text" name="t1"> (required)<br><br>
<b>Enter Salary:</b><input type="text" name="t2"> (required)<br><br>
<input type="button" value="validate" onClick="PinSal()">
</form>
</body>
</html>
5) JAVASCRIPT PROGRAM TO VALIDATE USER NAME & PASSWORD.

USERPWD.HTML

<html>
<head>
<title>Validation of User Name And Password</title>
<script language="javascript">
function check(name,pwd)
{
if(name.length<5 || name.length>30)
{
alert("Invalid username length. Please enter min. 5 characters.");
return false;
}

if(pwd.length<6 || pwd.length>12)
{
alert("Invalid password length. Password should be of 6 digits.");
return false;
}
for(i=0;i<name.length;i++)
{
var ch=name.substring(i,i+1);
if((((ch<"a" || ch>"z") && (ch<"A" || ch>"Z")) && isNaN(ch)) || ch==" ")
{
alert("Username can contain letters and digits only.");
return false;
}
}
for(i=0;i<pwd.length;i++)
{
var ch=pwd.substring(i,i+1);
if(ch==" ")
{
alert("Password cannot contain blank spaces.");
return false;
}
else
{
alert("Acceptable.");
return true;
}
}
}
</script>
</head>

<body bgcolor="white">
<form>
<h3>Member Login</h3><p>
Username : <input type="text" name="username" size=25 maxlength=30><P>
Password : <input type="password" name="password" size=10 maxlength=12><P>
<input type="submit" value="validate" onClick="check(username.value,password.value)">
&nbsp;&nbsp;&nbsp;<INPUT TYPE="reset" VALUE="Reset"></FORM>
</body>
</html>
6) JAVASCRIPT PROGRAM FOR EMAIL ID VALIDATION.

EMAILVALID.HTML
<html>
<head>
<script language = "Javascript">
function echeck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
alert("Please enter valid Email-ID !")
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
{
alert("Invalid Email-ID ! @ should be present but not at beginning or ending")
return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)


{
alert("Invalid Email-ID ! Dot(.) should be present but not at beginning or ending.")
return false
}

if (str.indexOf(at,(lat+1))!=-1)
{
alert("Invalid Email-ID..! Multiple @ not allowed.")
return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
{
alert("Invalid Email-ID ! Consecutive @ and dot not allowed.")
return false
}

if (str.indexOf(dot,(lat+2))==-1)
{
alert("Invalid Email-ID..! Consecutive dots not allowed.")
return false
}

if (str.indexOf(" ")!=-1)
{
alert("Invalid E-mail ID! Space is not allowed")
return false
}
alert("Acceptable.")
return true
}

function ValidateForm()
{
var emailID=document.frmSample.txtEmail

if ((emailID.value==null)||(emailID.value==""))
{
alert("Please Enter your Email ID")
emailID.focus()
return false
}
if (echeck(emailID.value)==false)
{
emailID.value=""
emailID.focus()
return false
}
return true
}
</script>
</head><body BGCOLOR="VIOLET">
<form name="frmSample" method="post" action="#" onSubmit="return ValidateForm()">
Enter an Email Address :
<input type="text" name="txtEmail">
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
7) JAVASCRIPT PROGRAM FOR EVENT DRIVEN CLIENT SIDE SCRIPT.

COLORCHANGE1.HTML

<html>
<body>
<script language=javascript>
var c=new Array("red","violet","green","yellow","lime","pink","cyan","orange","purple","lightgreen");
x=0;
function color()
{
col=c[x];
document.bgColor=col;
x=x+1;
if(x==10)
x=0;
window.setTimeout("color()",1000);
}

function c9()
{
window.status="info on status bar";
}

</script><center>
<form>
<input type=button value="Place ur Mouse Pointer Here" onMouseOver="color();">
<input type=button value="Click Here" onclick="color();">
</form>
</body>
</html>
COLORCHANGE2.HTML
<html>
<head>
<style>
h3{color="red";background-color="yellow"}
</style>
</head>
<body onLoad="color();" onUnload=alert("Closed.....!!!!");>
<script language=javascript>
var c=new Array("red","violet","green","yellow","lime","pink","cyan","orange","purple","lightgreen");
x=0;
function color()
{
col=c[x];
document.bgColor=col;
x=x+1;
if(x==7)
x=0;
window.setTimeout("color()",1000);
}
</script><center>
<marquee bgcolor="orange" amount="50%">
<h3>CONSTANTLY CHANGING COLOR USING JAVASCRIPT</h3>
</body>
</html>

Das könnte Ihnen auch gefallen