Posted by: Sourav | September 27, 2016

Practical Stack Class Example,VB teacher Sourav,Kolkata 09748184075


Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web

Public Class BasePage
Inherits System.Web.UI.Page
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
Dim urlstack As Stack(Of String)
If Session(“stackofurls”) Is Nothing Then
urlstack = New Stack(Of String)
Session(“stackofurls”) = urlstack

End If
If (Not Request.UrlReferrer Is Nothing) And (Me.Page.IsPostBack = False) And (Session(“backbuttonclicked”) Is Nothing) Then
urlstack = DirectCast(Session(“stackofurls”), Stack(Of String))
urlstack.Push(Request.UrlReferrer.AbsolutePath)
End If

If Not Session(“backbuttonclicked”) Is Nothing Then
Session(“backbuttonclicked”) = Nothing

End If
‘MyBase.OnLoad(e)
End Sub

End Class

 

Site1.master code

<%@ Master Language=”VB” AutoEventWireup=”false” CodeBehind=”Site1.master.vb” Inherits=”practicalstackexamplevb.Site1″ %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head runat=”server”>
<title></title>
<asp:ContentPlaceHolder ID=”head” runat=”server”>
</asp:ContentPlaceHolder>
</head>
<body>
<form id=”form1″ runat=”server”>

<table style=”border:1px solid black; width:500px;  font-family:Arial;”>
<tr>
<td colspan=”2″>
<asp:Label ID=”Label1″ runat=”server” ForeColor=”Red”  ></asp:Label>
</td>

</tr>
<tr>
<td style=”width: 100px;”>
<table>
<tr>
<td>
<b>Links</b>
</td>
</tr>
<tr>
<td>
<a href=”http://localhost:51243/WebForm1.aspx”>Webform 1</a>

</td>
</tr>
<tr>
<td>
<a href=”http://localhost:51243/WebForm2.aspx”>Webform 2</a>
</td>
</tr>
<tr>
<td>
<a href=”http://localhost:51243/WebForm3.aspx”>Webform 3</a>
</td>
</tr>
<tr>
<td>
<a href=”http://localhost:51243/WebForm4.aspx”>Webform 4</a>
</td>
</tr>

</table>
</td>
<td>
<asp:Button ID=”Button1″ runat=”server” Text=”Back” />
<asp:ContentPlaceHolder ID=”ContentPlaceHolder1″ runat=”server”>

</asp:ContentPlaceHolder>

</td>
</tr>

</table>

</form>
</body>
</html>

Public Class Site1
Inherits System.Web.UI.MasterPage

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
Session(“backbuttonclicked”) = “YES”
If Not Session(“stackofurls”) Is Nothing Then
Dim urlstack As Stack(Of String) = DirectCast(Session(“stackofurls”), Stack(Of String))
If urlstack.Count > 0 Then
Dim url As String = urlstack.Pop
Response.Redirect(url)

Else
Label1.Text = “There are no page in the history”
End If

End If
End Sub
End Class

right click on site1.master and add content page

webform1.aspx

webform2.aspx

webform3.aspx

webform1.aspx

and then

webform1.aspx.vb

 

Public Class WebForm1
Inherits BasePage

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

End Sub

End Class

webform2.aspx.vb

Public Class WebForm1
Inherits BasePage

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

End Sub

End Class

webform3.aspx.vb

Public Class WebForm1
Inherits BasePage

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

End Sub

End Class

webform4.aspx.vb

Public Class WebForm1
Inherits BasePage

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

End Sub

End Class

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: