Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//////////C#/ASPX Help////////// Need help with my aspx programming homework. I

ID: 3885707 • Letter: #

Question

//////////C#/ASPX Help//////////

Need help with my aspx programming homework. I have most some of the work started but have run into confusion as to where to go next. I need to make a webform that gets input data and displays price and carries over data from one webform to the next page, using the Session Object. In my file my button function doesn't seem to work in my .cs file so that's what left me confused.

External Link

https://www.dropbox.com/sh/cau5r4upgx9g4vm/AAAHcBI_6SrPfzeSWVvUO57Qa?dl=0

In this link is the Assignment details and my aspx files that I started working on. Some help would be appreciated.

Explanation / Answer

Webform1.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Week2test.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <table>

            <tr>

                <td>

                    <strong>First Name</strong>

                </td>

                <td>

                    <asp:Textbox ID="txtFirst" runat="server"></asp:Textbox>

                </td>

            </tr>

            <tr>

                <td>

                    <strong>Last Name</strong>

                </td>

                <td>

                    <asp:TextBox ID="txtLast" runat="server"></asp:TextBox>

                </td>

            </tr>

            <tr>

                <td>

                    <strong>Please select a date that you would need it</strong>

                </td>

                <td>

                    <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>

                </td>

            </tr>

            <tr>

                <td>

                    <strong>Select State</strong>

                </td>

                <td>

                    <asp:DropDownList ID="DropDownListState" runat="server">

                        <asp:ListItem Value="KS">Kansas</asp:ListItem>

                        <asp:ListItem Value="MO">Missouri</asp:ListItem>

                        <asp:ListItem Value="KY">Kentucky</asp:ListItem>

                        <asp:ListItem Value="CO">Colorado</asp:ListItem>

                        <asp:ListItem Value="DC">District of Columbia</asp:ListItem>

                    </asp:DropDownList>

                </td>

            </tr>

            <tr>

                <td>

                    <strong>Select Background Color</strong>

                </td>

                <td>

                    <asp:CheckBox Text="Red" ID="chkRed" runat="server" />

                    <asp:CheckBox Text="White" ID="chkWhite" runat="server" />

                    <asp:CheckBox Text="Green" ID="chkGreen" runat="server" />

                    <asp:CheckBox Text="Blue" ID="chkBlue" runat="server" />

                    <asp:CheckBox Text="Gray" ID="chkGray" runat="server" />

                </td>

            </tr>

            <tr>

                <td>

                    <strong>Choose Border Style</strong>

                </td>

                <td>

                    <asp:CheckBox Text="Rectangle" ID="chkRectangle" runat="server" />

                    <asp:CheckBox Text="Square" ID="chkSquare" runat="server" />

                    <asp:CheckBox Text="Circle" ID="chkCircle" runat="server" />

                </td>

            </tr>

            <tr>

                <td>

                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" />

                </td>

            </tr>

        </table>

     

    </div>

    </form>

</body>

</html>

Webform1.aspx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace Week2test

{

    public partial class WebForm1 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

        }

        protected void btnSubmit_Click(object sender, EventArgs e)

{

            Session["First"] = txtFirst.Text;

            Session["Last"] = txtLast.Text;

            Session["Calendar"] = Calendar1.Text;

            Session["State"] = DropDownListState.Text;

            Response.Redirect("~/Webform2.aspx");

}

    }

}

Webform2.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="Week2test.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<h2>Webform1 Data is Displayed here</h2>

<div>

<table>

<tr>

<td>

<strong>First Name</strong>

</td>

<td>

<asp:Label ID="lblFirstName" runat="server"></asp:Label>

</td>

</tr>

<tr>

<td>

<strong>Last Name</strong>

</td>

<td>

<asp:Label ID="lblLastName" runat="server"></asp:Label>

</td>

</tr>

<tr>

<td>

<strong>Selected Date</strong>

</td>

<td>

<asp:Label ID="lblDate" runat="server"></asp:Label>

</td>

</tr>

<tr>

<td>

<strong>Selected State</strong>

</td>

<td>

<asp:Label ID="lblState" runat="server"></asp:Label>

</td>

</tr>

  

</table>

</div>

</form>

</body>

</html>

WebForm2.aspx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace Week2test

{

public partial class WebForm2 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

BindValue();

}

public void BindValue()

{

// Here we are assigning the value entered in the textbox to label by using session.

lblFirstName.Text=Session["First"].ToString();

  

lblLastName.Text=Session["Last"].ToString();

lblDate.Text=Session["Calendar"].ToString();

lblState.Text=Session["State"].ToString();

}

}

}