Click here to Skip to main content
15,893,668 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Component based architecture Pin
Viral Upadhyay14-Apr-10 21:16
Viral Upadhyay14-Apr-10 21:16 
QuestionCreating a forum in ASP.NET Pin
Eagle3214-Apr-10 11:58
Eagle3214-Apr-10 11:58 
AnswerRe: Creating a forum in ASP.NET Pin
Sandeep Mewara14-Apr-10 21:09
mveSandeep Mewara14-Apr-10 21:09 
AnswerRe: Creating a forum in ASP.NET Pin
David Mujica15-Apr-10 9:45
David Mujica15-Apr-10 9:45 
QuestionHttpResponse Pin
hb5213421414-Apr-10 11:12
hb5213421414-Apr-10 11:12 
AnswerRe: HttpResponse Pin
Gregory Gadow15-Apr-10 3:34
Gregory Gadow15-Apr-10 3:34 
GeneralRe: HttpResponse Pin
hb5213421415-Apr-10 4:07
hb5213421415-Apr-10 4:07 
QuestionC# webform help Pin
Jordan McGehee14-Apr-10 9:00
Jordan McGehee14-Apr-10 9:00 
Hey guys,

I am new to C# and know very little about ASP.net and classes in general. All that to say I got a project file for Visual Studio 2008 that is a C# web form that is suppose to allow you to enter address info: Street, City, State and Zip and then in a text box below shows that info in a mailing address format, e.g.

123 Easy St.
Anytown CA, 98541

Anyway its got other classes in it and the webform .cs file has nothing in it. I was wondering why they did not use the .cs file from the web form also it has lots of errors in it, I guess because it can't connect the proper classes. In fact if I run as is it says:

"'ASP.default_aspx' does not contain a definition for 'btnGetAddress_Click' and no extension method 'btnGetAddress_Click' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?) C:\Users\Jordan McGehee\Desktop\AddressApp\Default.aspx 59

Why will it not run? Also can it be simplified using the web form (default) class? I am trying to get to know ASP.net but don't have a lot of direction.

Here is the .aspx code for the form itself, if you need the project file I can e-mail to you I didn't see a place to put attachments:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" 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></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 128px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    
    <table class="style1">
        <tr>
            <td class="style2">
                Street:</td>
            <td>
                <asp:TextBox ID="txtStreet" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                City:</td>
            <td>
                <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                State:</td>
            <td>
                <asp:TextBox ID="txtState" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                Zip Code:</td>
            <td>
                <asp:TextBox ID="txtZipCode" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                &nbsp;</td>
            <td>
                <textarea id="txtAddressArea" cols="20" name="S1" readonly="readonly" rows="2"></textarea></td>
        </tr>
        <tr>
            <td class="style2">
                <asp:Button ID="btnGetAddress" runat="server" onclick="btnGetAddress_Click" 
                    Text="Get Address" />
            </td>
            <td>
                <asp:Button ID="btnClear" runat="server" Text="Clear" />
            </td>
        </tr>
    </table>
    
    </form>
</body>
</html>


And here is the code for the Address Class:

using System;
using System.Collections.Generic;
using System.Text;

namespace AddressApp
{
    class Address
    {
        //variable declarations
        private string street;
        private string city;
        private string state;
        private string zipcode;

        //Getters and Setters

        //street getter and setter method
        public string getStreet()
        {
            return street;
        }
        public void setStreet(string street)
        {
            this.street = street;
        }
        //city getter and setter method
        public string getCity()
        {
            return city;
        }
        public void setCity(string city)
        {
            this.city = city;
        }

        //state getter and setter method
        public string getState()
        {
            return state;
        }
        public void setState(string state)
        {
            this.state = state;
        }

        //zip getter and setter method
        public string getZipCode()
        {
            return zipcode;
        }
        public void setZipCode(string zipcode)
        {
            this.zipcode = zipcode;
        }
    }
}


and a frmAddress class:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace AddressApp
{
    public partial class frmaddress : Form
    {
        public frmaddress()
        {
            InitializeComponent();
        }

        //button click event
        private void btnGetAddress_Click(object sender, EventArgs e)
        {
            //method to add address in to address class and display in textarea
            addaddress();
        }
        public void addaddress()
        {
            //clearing the text area every time 
            txtareaaddress.Text = "";

            //Address class object creation and storing values in to address class
            Address a = new Address();
            a.setStreet(txtStreet.Text);
            a.setCity(txtCity.Text);
            a.setState(txtState.Text);
            a.setZipCode(txtZipCode.Text);

            //printing it in text area

            txtareaaddress.AppendText(a.getStreet());
            txtareaaddress.AppendText(".");
            txtareaaddress.AppendText(Environment.NewLine);
            txtareaaddress.AppendText(a.getCity());
            txtareaaddress.AppendText("   ");
            txtareaaddress.AppendText(",");
            txtareaaddress.AppendText(a.getState());
            txtareaaddress.AppendText("   ");

            txtareaaddress.AppendText(a.getZipCode());


        }

        //clear control button click
        private void btnClear_Click(object sender, EventArgs e)
        {
            ClearControls();
        }
        //clears text in controls
        public void ClearControls()
        {
            txtStreet.Text = "";
            txtZipCode.Text = "";
            txtCity.Text = "";
            txtState.Text = "";
            txtareaaddress.Text = "";

        }
    }
}

AnswerRe: C# webform help Pin
Not Active14-Apr-10 10:11
mentorNot Active14-Apr-10 10:11 
GeneralRe: C# webform help Pin
Jordan McGehee14-Apr-10 10:31
Jordan McGehee14-Apr-10 10:31 
GeneralRe: C# webform help Pin
Not Active14-Apr-10 16:18
mentorNot Active14-Apr-10 16:18 
QuestionHow to access RDLC matrix subtotal value? Pin
JimFeng14-Apr-10 7:07
JimFeng14-Apr-10 7:07 
AnswerRe: How to access RDLC matrix subtotal value? Pin
Sandeep Mewara14-Apr-10 21:17
mveSandeep Mewara14-Apr-10 21:17 
GeneralRe: How to access RDLC matrix subtotal value? Pin
JimFeng15-Apr-10 3:06
JimFeng15-Apr-10 3:06 
Questiongridview Pin
tek 200914-Apr-10 5:52
tek 200914-Apr-10 5:52 
AnswerRe: gridview Pin
Not Active14-Apr-10 5:59
mentorNot Active14-Apr-10 5:59 
QuestionRe: gridview Pin
tek 200914-Apr-10 6:21
tek 200914-Apr-10 6:21 
AnswerRe: gridview Pin
Not Active14-Apr-10 8:30
mentorNot Active14-Apr-10 8:30 
AnswerRe: gridview Pin
David Mujica14-Apr-10 6:09
David Mujica14-Apr-10 6:09 
QuestionCurrent theme Pin
paper6714-Apr-10 5:12
paper6714-Apr-10 5:12 
AnswerRe: Current theme Pin
michaelschmitt14-Apr-10 5:27
michaelschmitt14-Apr-10 5:27 
GeneralRe: Current theme Pin
paper6714-Apr-10 6:05
paper6714-Apr-10 6:05 
GeneralRe: Current theme Pin
michaelschmitt14-Apr-10 23:25
michaelschmitt14-Apr-10 23:25 
GeneralRe: Current theme Pin
paper6715-Apr-10 2:55
paper6715-Apr-10 2:55 
GeneralRe: Current theme Pin
michaelschmitt15-Apr-10 3:28
michaelschmitt15-Apr-10 3:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.