Thursday, May 13, 2010

MasterPage.master

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

<!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>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Master States Two</h1>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

</asp:ContentPlaceHolder>
<p><a href="Default3.aspx">Confirmation</a></p>
</div>
</form>
</body>
</html>

Default2.aspx

<%@ Page Title="Donation form" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<meta content="copyrighted by me" name="about" />
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>Donate</h2>
<p>
<asp:Label ID="Label1" runat="server" Text="First Name"></asp:Label> 
<asp:TextBox
ID="txtFirstName" runat="server"></asp:TextBox> <br />

<asp:Label ID="Label2" runat="server" Text="* Last Name"></asp:Label> 
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtLastName" ErrorMessage="Please Enter Last name"
Display="None"></asp:RequiredFieldValidator>
<br />

<asp:Label ID="Label3" runat="server" Text="* Donation Amount"></asp:Label>
<asp:TextBox ID="txtDonation" runat="server"></asp:TextBox>

<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtDonation" ErrorMessage="Please enter a donation"
Display="None"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ErrorMessage="Enter a valid numerical amount" Type="Double"
Operator="DataTypeCheck" ControlToValidate="txtDonation" Display="None"></asp:CompareValidator>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />

</p>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<p>
 </p>

</asp:Content>

Default2.aspx.vb


Partial Class Default2
Inherits System.Web.UI.Page

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
'PassByQueryString()

PassBySessionVariable()


End Sub

Protected Sub PassByQueryString()
Dim first As String = txtFirstName.Text
Dim last As String = txtLastName.Text
Dim donation As String = txtDonation.Text

Response.Redirect("Default3.aspx?firstname=" & first & "&lastname=" & last & "&donation=" & donation)
End Sub

Protected Sub PassBySessionVariable()
Dim first As String = txtFirstName.Text
Dim last As String = txtLastName.Text
Dim donation As String = txtDonation.Text

Session("firstname") = first
Session("lastname") = last
Session("donation") = donation

Response.Redirect("Default3.aspx")
End Sub
End Class

Default3.aspx

<%@ Page Title="Confirmation" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2>Confirm</h2>
<asp:Label ID="lblFirstName" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="lblLastName" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="lblDonation" runat="server" Text="Label"></asp:Label><br />
<asp:Label ID="Label1" runat="server" Text="thank You"></asp:Label>
</asp:Content>

Default3.aspx.vb


Partial Class Default3
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'GetFromQueryString()
If Session("lastname") = Nothing Then
Response.Redirect("Default2.aspx")
Else
GetFromSessionVariable()
End If

End Sub

Public Sub GetFromQueryString()
lblFirstName.Text = Request.QueryString("firstname")
lblLastName.Text = Request.QueryString("lastname")
lblDonation.Text = Request.QueryString("donation")
End Sub

Protected Sub GetFromSessionVariable()
lblFirstName.Text = Session("firstname")
lblLastName.Text = Session("lastname")
lblDonation.Text = Session("donation")
End Sub
End Class

No comments:

Post a Comment