This is driving me insane. I want to do something simple but have no idea because I am an absolute beginner. I want to take whats in the text boxes, and put them into 1 label, then make that label visible. I keep getting this error no matter what I try, "The name 'submittedData' does not exist in this context. What am I doing wrong?
Here is the code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void submit_Click(object sender, EventArgs e)
{
submittedData.Text = name.Text + " " + email.Text + " " + phone.Text;
submittedData.Visible = true;
}
}
And the aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link rel="stylesheet" type="text/css" href="StyleSheet.css"></link>
<title>Coding Club</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Coding club registration form</h1>
<label for="name">Your Name:</label>
<asp:TextBox ID="name" runat="server" TextMode="SingleLine"></asp:TextBox>
</div>
<div>
<label for="email">Your Email:</label>
<asp:TextBox ID="email" runat="server" TextMode="SingleLine"></asp:TextBox>
</div>
<div>
<label for="phone">Your Phone:</label>
<asp:TextBox ID="phone" runat="server" TextMode="SingleLine"></asp:TextBox>
</div>
<div>
<asp:Button ID="submit" runat="server" Text="Submit" onclick="submit_Click" />
<asp:Button ID="clear" runat="server" Text="Clear Form" />
</div>
<div>
<label for="submittedData" runat="server"></label>
</div>
</form>
</body>
</html>