help with ASP.net?

Discussion in 'OT Technology' started by legendr34, Oct 23, 2003.

  1. legendr34

    legendr34 Titanium Member

    Joined:
    Jun 26, 2000
    Messages:
    4,433
    Likes Received:
    0
    Location:
    SoCal
    Hi

    I have this program which I need help on, wondering if anyone can help me on this.

    this is the outline of the assingment:

    http://staffwww.fullcoll.edu/jcourchaine/CIS220/Assignment2/CIS220 Assignment2.htm

    and this is what I have now:

    Code:
     <%@ Page Debug="True" Language="VB" %>
    <script runat="server">
    
        Sub viewcart(sender As Object, e As EventArgs)
                lblcookie.Text=dropproducts.selecteditem.value & dropquantity.selecteditem.value
             End Sub
    
    
    
    </script>
    <html>
    <head>
    </head>
    <body>
        <form runat="server">
            <p>
                <asp:Label id="lblcookie" runat="server"></asp:Label>
            </p>
            <p>
                <strong><font size="4">CIS-220 Web Programming Assignment #2 </font></strong>
            </p>
            <p>
                <strong><font size="4">Phil Park</font></strong>
            </p>
            <p>
            </p>
            Customer Name:
            <asp:TextBox id="txtCustomerName" runat="server"></asp:TextBox>
            <p>
                Products:
                <asp:DropDownList id="dropproducts" runat="server">
                    <asp:listitem>Coat</asp:listitem>
                    <asp:listitem>Gloves</asp:listitem>
                    <asp:listitem>Hat</asp:listitem>
                    <asp:listitem>Pants</asp:listitem>
                    <asp:listitem>Sandals</asp:listitem>
                    <asp:listitem>Shirt</asp:listitem>
                    <asp:listitem>Socks</asp:listitem>
                    <asp:listitem>Shoes</asp:listitem>
                    <asp:listitem>Shorts</asp:listitem>
                    <asp:listitem>Sweater</asp:listitem>
                </asp:DropDownList>
                &nbsp;Quantity:
                <asp:DropDownList id="dropquantity" runat="server">
                    <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>6</asp:listitem>
                    <asp:listitem>7</asp:listitem>
                    <asp:listitem>8</asp:listitem>
                    <asp:listitem>9</asp:listitem>
                    <asp:listitem>10</asp:listitem>
                </asp:DropDownList>
            </p>
            <p>
                <asp:RadioButton id="rdovisacard" runat="server" Text="Visa Card"></asp:RadioButton>
                &nbsp;<asp:RadioButton id="rdomastercard" runat="server" Text="Master Card"></asp:RadioButton>
                &nbsp;<asp:RadioButton id="rdodiscovercard" runat="server" Text="Discover Card"></asp:RadioButton>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Expiration Date:<asp:TextBox id="txtexpiration" runat="server"></asp:TextBox>
            </p>
            <p>
                <asp:Button input type="hidden" id="btnAddItem" runat="server" Text="Add Item to Cart" Width="113px"></asp:Button>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button id="btnViewShopping" onclick="ViewCart" runat="server" Text="View Shopping Cart" Width="135px"></asp:Button>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button id="btnEmptyShopping" onlclick="emptycart" runat="server" Text="Empty Shopping Cart" Width="136px"></asp:Button>
            </p>
            <p>
            </p>
        </form>
    </body>
    </html>
    
    
    
     
    Last edited: Oct 23, 2003
  2. carlin

    carlin Guest

    first things first....change the {quote} tag to
    Code:
     please
     
  3. carlin

    carlin Guest

    Code:
    <script runat="server">
    
        <%@ Page Debug="True" Language="VB" %>
        <script runat="server">
        
            Sub viewcart(sender As Object, e As EventArgs)
                    lblcookie.Text=dropproducts.selecteditem.value & dropquantity.selecteditem.value
                 End Sub
    
    </script>
    
    you have a runat nested inside another runat script tag for one...what is the error you are getting?
     
  4. legendr34

    legendr34 Titanium Member

    Joined:
    Jun 26, 2000
    Messages:
    4,433
    Likes Received:
    0
    Location:
    SoCal
    hi carlin, i just corrected it....it runs, but i don't know how to make it work like the working example
     
  5. carlin

    carlin Guest

    seeing that i dont know much of vb or vb.net... i gave it a shot...it only does the cookie for product stuff
    filename: WebForm1.aspx
    Code:
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="SampleVBApp2.WebForm1"%>
    <HTML>
    	<HEAD>
    	</HEAD>
    	<body>
    		<form runat="server" ID="Form1">
    			<p>
    				<asp:Label id="lblcookie" runat="server"></asp:Label>
    			</p>
    			<p>
    				<strong><font size="4">CIS-220 Web Programming Assignment #2 </font></strong>
    			</p>
    			<p>
    				<strong><font size="4">Phil Park</font></strong>
    			</p>
    			<p>
    			</p>
    			Customer Name:
    			<asp:TextBox id="txtCustomerName" runat="server"></asp:TextBox>
    			<p>
    				Products:
    				<asp:DropDownList id="dropproducts" runat="server">
    					<asp:listitem>Coat</asp:listitem>
    					<asp:listitem>Gloves</asp:listitem>
    					<asp:listitem>Hat</asp:listitem>
    					<asp:listitem>Pants</asp:listitem>
    					<asp:listitem>Sandals</asp:listitem>
    					<asp:listitem>Shirt</asp:listitem>
    					<asp:listitem>Socks</asp:listitem>
    					<asp:listitem>Shoes</asp:listitem>
    					<asp:listitem>Shorts</asp:listitem>
    					<asp:listitem>Sweater</asp:listitem>
    				</asp:DropDownList>
    				&nbsp;Quantity:
    				<asp:DropDownList id="dropquantity" runat="server">
    					<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>6</asp:listitem>
    					<asp:listitem>7</asp:listitem>
    					<asp:listitem>8</asp:listitem>
    					<asp:listitem>9</asp:listitem>
    					<asp:listitem>10</asp:listitem>
    				</asp:DropDownList>
    			</p>
    			<p>
    				<asp:RadioButton id="rdovisacard" runat="server" Text="Visa Card"></asp:RadioButton>
    				&nbsp;<asp:RadioButton id="rdomastercard" runat="server" Text="Master Card"></asp:RadioButton>
    				&nbsp;<asp:RadioButton id="rdodiscovercard" runat="server" Text="Discover Card"></asp:RadioButton>
    				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Expiration Date:<asp:TextBox id="txtexpiration" runat="server"></asp:TextBox>
    			</p>
    			<p>
    				<asp:Button input type="hidden" id="btnAddItem" runat="server" Text="Add Item to Cart" Width="113px"></asp:Button>
    				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    				<asp:Button id="btnViewShopping" onclick="ViewCart" runat="server" Text="View Shopping Cart" Width="135px"></asp:Button>
    				&nbsp;&nbsp;&nbsp;&nbsp;
    				<asp:Button id="btnEmptyShopping" onlclick="emptycart" runat="server" Text="Empty Shopping Cart" Width="136px"></asp:Button>
    			</p>
    			<p>
    			</p>
    		</form>
    	</body>
    </HTML>
    
    filename: WebForm1.aspx.vb
    Code:
    Public Class WebForm1
        Inherits System.Web.UI.Page
        Protected WithEvents lblcookie As System.Web.UI.WebControls.Label
        Protected WithEvents txtCustomerName As System.Web.UI.WebControls.TextBox
        Protected WithEvents dropproducts As System.Web.UI.WebControls.DropDownList
        Protected WithEvents dropquantity As System.Web.UI.WebControls.DropDownList
        Protected WithEvents rdovisacard As System.Web.UI.WebControls.RadioButton
        Protected WithEvents rdomastercard As System.Web.UI.WebControls.RadioButton
        Protected WithEvents rdodiscovercard As System.Web.UI.WebControls.RadioButton
        Protected WithEvents txtexpiration As System.Web.UI.WebControls.TextBox
        Protected WithEvents btnAddItem As System.Web.UI.WebControls.Button
        Protected WithEvents btnViewShopping As System.Web.UI.WebControls.Button
        Protected WithEvents btnEmptyShopping As System.Web.UI.WebControls.Button
        Protected cookie As HttpCookie = New HttpCookie("My Cookie")
    
    #Region " Web Form Designer Generated Code "
    
        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    
        End Sub
    
        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub
    
    #End Region
    
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
        End Sub
    
        Sub viewcart(ByVal sender As Object, ByVal e As EventArgs)
            'lblcookie.Text = dropproducts.selecteditem.value & dropquantity.selecteditem.value
            'Dim count As Integer
            'For count = 0 To cookie.Values.Keys.Count Step 1
            'Response.Write(cookie.Value())
            'Next
    
            Dim iPart As IEnumerator
            Dim httpCookie As HttpCookie
    
            httpCookie = Request.Cookies("cookie")
    
            iPart = httpCookie.Values.GetEnumerator()
            While iPart.MoveNext
                lblcookie.Text = lblcookie.Text & "<br />" & iPart.Current & ":" & httpCookie.Values.Get(iPart.Current)
            End While
            Response.Write("Done printing list")
    
        End Sub
    
        Private Sub btnAddItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddItem.Click
            'cookie.Values.Add(dropproducts.SelectedItem.Text, dropquantity.SelectedItem.Text)
            'Response.AppendCookie(cookie)
            'Response.Cookies.Add(cookie)
    
            Dim cookie As HttpCookie = Request.Cookies("cookie")
            If cookie Is Nothing Then
                cookie = New HttpCookie("cookie")
            End If
            cookie(dropproducts.SelectedItem.Text) = dropquantity.SelectedItem.Text
    
            Response.AppendCookie(cookie)
        End Sub
    End Class
    
    you can get rid of the second file by adding the methods into the aspx file and changing the first line in the aspx file
     

Share This Page