Wednesday, 1 April 2015
Wednesday, 23 July 2014
asp.net 13: dropdown list(auto postback)
program to select roll number and display name vice versa using auto post back property.
-----------------------------------------DESIGN-----------------------------------------------------
-----------------------------------------code---------------------------------------------------------
-----------------------------------------output----------------------------------------------------
-----------------------------------------DESIGN-----------------------------------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" ForeColor="Red"
Text="DEMO OF AUTOPOSTBACK PROPERTY"></asp:Label>
<br />
<br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem>Select Enrollment No</asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
<br />
<br />
</div>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
Height="38px" Width="148px">
<asp:ListItem>Select Name</asp:ListItem>
<asp:ListItem>Meru</asp:ListItem>
<asp:ListItem>Johar</asp:ListItem>
<asp:ListItem>sanjay</asp:ListItem>
<asp:ListItem>Akshay</asp:ListItem>
<asp:ListItem>Nikunj</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="OK" />
<br />
<br />
<asp:ListBox ID="ListBox1" runat="server" Height="126px" Width="145px">
</asp:ListBox>
</form>
</body>
</html>
-----------------------------------------code---------------------------------------------------------
Partial Class _Default
Inherits System.Web.UI.Page
Dim a As Integer
Dim b As Integer
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
a = DropDownList1.SelectedIndex
DropDownList2.SelectedIndex = a
ListBox1.Items.Clear()
End Sub
Protected Sub DropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged
b = DropDownList2.SelectedIndex
DropDownList1.SelectedIndex = b
ListBox1.Items.Clear()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add("Enrollment No:" & DropDownList1.SelectedItem.ToString())
ListBox1.Items.Add("Name:" & DropDownList2.SelectedItem.ToString())
End Sub
End Class-----------------------------------------output----------------------------------------------------
![]() |
|
| codestrew |
Saturday, 7 June 2014
program 23: interface
program to demonstrate concept of interface.
-----------------------------------------code---------------------------------------------------------
Imports System.Console
Module Module1
Sub Main()
Dim obj1 As New one
Dim obj2 As New two
obj1.disp()
obj1.multiply()
obj2.disp()
obj2.multiply()
ReadKey()
End Sub
End Module
Public Interface test
Sub disp()
Function multiply() As Double
End Interface
Public Class one
Implements test
Public i As Double = 12
Public j As Double = 12.17
Public Sub disp() Implements test.disp
WriteLine("sum=" & i + j)
End Sub
Public Function multiply() As Double Implements test.multiply
WriteLine("muliplication=" & i * j)
End Function
End Class
Public Class two
Implements test
Public a As Double = 20
Public b As Double = 32.17
Public Sub disp() Implements test.disp
WriteLine("Welcome to interface")
End Sub
Public Function multiply() As Double Implements test.multiply
WriteLine("multiplication=" & a * b)
End Function
End Class-----------------------------------------output----------------------------------------------------
![]() |
| codestrew |
program 22: abstract class
program to demonstrate concept of abstract and
not inheritable class.
-----------------------------------------code---------------------------------------------------------
End Module
-----------------------------------------output----------------------------------------------------
-----------------------------------------code---------------------------------------------------------
Imports
System.Console
Module Module1
Public MustInherit Class
abstractclass
Public MustOverride Function
add() As Integer
Public MustOverride Function
mul() As Integer
End Class
Public Class abstractone
Inherits
abstractclass
Dim i As Integer = 20
Dim j As Integer = 30
Public Overrides Function
add() As Integer
Return
i + j
End Function
Public Overrides Function
mul() As Integer
Return
i * j
End Function
End Class
Sub Main()
Dim a As New abstractone
WriteLine("sum
is:" & a.add())
WriteLine("multiplication
is:" & a.mul())
ReadKey()
End Sub
-----------------------------------------output----------------------------------------------------
![]() |
| codestrew |
program 21: base class construction
program to
demonstrate concept of base class construction.
Imports
System.Console
Module Module1
Sub Main()
Dim w As New window(10, 5)
w.drawwindow()
Dim lb As New listbox(20,
30, "hello..!!")
lb.drawwindow()
Console.ReadKey()
End Sub
End Module
Public Class window
Private top
As Integer
Private
left As Integer
Public Sub New(ByVal top As Integer, ByVal left As Integer)
Me.top
= top
Me.left
= left
End Sub
Public Sub drawwindow()
WriteLine("Drawing
window at {0},{1}", top, left)
End Sub
End Class
Public Class listbox
Inherits
window
Public Sub New(ByVal top As Integer, ByVal left As Integer, ByVal tcontent As String)
MyBase.New(top,
left)
mlstboxcontent = tcontent
End Sub
Public Shadows Sub
drawwindow()
Console.WriteLine("..........")
MyBase.drawwindow()
Console.WriteLine("Writing string to the listbox:{0}",
mlstboxcontent)
End Sub
Private
mlstboxcontent As String
End Class-----------------------------------------output----------------------------------------------------
![]() |
| codestrew |
program 20: inheritance
program to
demonstrate concept of inheritance.
-----------------------------------------code---------------------------------------------------------
Module Module1
Class A
Public Sub Show()
Console.WriteLine("Calling from A")
End Sub
End Class
Class B
Inherits
A
Public Shadows Sub Show()
Console.WriteLine("Calling from B")
End Sub
End Class
Class C
Inherits
B
Public Shadows Sub Show()
Console.WriteLine("Calling from C")
End Sub
End Class
Public Sub Main()
Dim x As New A
x.Show()
x.Show()
x.Show()
Dim y As New B
y.Show()
Dim p1 As New C
p1.Show()
Console.ReadKey()
End Sub
End Module-----------------------------------------output----------------------------------------------------
![]() |
| codestrew |
Subscribe to:
Posts (Atom)




