{tab iisexpress error}

{tab Starting My First Web App}

{tab My First Web App}

{tab Visual Studio Notes}

{/tabs}

  1. type What is your first name? (Double space space):
  2. in Toolbox double click on TextBox:
  3. use arrow key to go to end of TexBox:
  4. press enter key twice:

  1. type What is your last name?  (Double space space):
  2. in Toolbox double click on TextBox:
  3. use arrow key to go to end of TexBox:
  4. press enter key twice:

  1. in Toolbox double click to insert Botton:
  2. use arrow key to go to end of Botton:
  3. press enter key twice:

  1. in Toolbox double click to insert Label:

  1. Select first TextBox:
  2. goto Properties Box (lower right hand side):
  3. find (ID): Type, firstNameTextBox:
  4. hit Enter key:

  1. Select second TextBox:
  2. goto Properties Box (lower right hand side):
  3. find (ID): Type, lastNameTextBox:
  4. hit Entere key:

  1. Select Botton control:
  2. goto Properties box:
  3. find (ID): Type, OkButton:
  4. Under Appearance category:
  5. find Text: Type, Click Me:
  6. hit Enter key:

  1. Select Label conrol:
  2. Under Misc category:
  3. find (ID): Type, resultLabel
  4. Under Appearance category:
  5. find Text: in textbox delete Lablel to remove the text:
  6. hit Enter key:

  1. Double click, Click Me Botton:
  2. It will open a new file called: Default.aspx.cs
  3. Make sure curse in inside: protected void OkButton_Click(object sender, EventArgs e)
  4. inside the the curley braces type :
            {
                string firstName = firstNameTextBox.Text;
                string lastName = lastNameTextBox.Text;

                string result = "Hello " + firstName + " " + lastName;

                resultLabel.Text = result;
            }

  1. Save your work:
  2. Now Run your work:
  3. Click the Green Arrow

Default.aspx

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form2" runat="server">
        <div>
            What is your first name?&nbsp;
            <asp:TextBox ID="firstNameTextBox" runat="server"></asp:TextBox>
            <br />
            <br />
            What is your last name?&nbsp;
            <asp:TextBox ID="lastNameTextBox" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="OkButton" runat="server" OnClick="OkButton_Click" Text="Click Me" />
            <br />
            <br />
            <asp:Label ID="resultLabel" runat="server"></asp:Label>
        </div>
    </form>
</body>
</html>

Default.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MyFirstWebApp
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void OkButton_Click(object sender, EventArgs e)
        {
            string firstName = firstNameTextBox.Text;
            string lastName = lastNameTextBox.Text;

            string result = "Hello " + firstName + " " + lastName;

            resultLabel.Text = result;
        }

    }
}