Friday, 6 September 2013

Can't Access Textbox in ASP

Can't Access Textbox in ASP

I have a simple ASP.NET page with a button and a textbox, I want to click
the button and have "Hello" appear in the textbox.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="File.aspx.cs"
Inherits="SOM" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div><br />
</div>
<asp:Button ID="MyBtn" runat="server" Text="Click"
OnClick="ClickBtn_Click" />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Width="268px"></asp:TextBox>
in the code behind I am able to use Intellisence to autocomplete
TextBox1.Text = "Hello";
but then when I try to debug, the project fails to build saying
The name TextBox1 does not exist in the current context
Is there a property that I need to set?

No comments:

Post a Comment