|
 |
aspx_beginners thread: Code Behind
Message #1 by "Marni Alvarez" <marni@f...> on Tue, 23 Apr 2002 10:05:55 -0700
|
|
MessageHi there.
I am reading the book Professional ASP.NET version 1.0 and am trying to do
the code behind example on pages 29-30. But I am getting the following
error:
Compiler Error Message: BC30451: Name 'YourName' is not declared.
I tried adding the Name="YourName" property, but that didn't work either.
The code is right from the book. Any ideas?
' TestASPX.aspx
<@Page Language="VB" Inherits="Ch1CodeBehind"
Src="Components\Ch1CodeBehind.vb" %>
<html>
<body>
<form runat="server">
Enter Your Name: <asp:TextBox ID="Name" Runat="server" />
<br />
Press Button: <asp:Button OnClick="btn_Click" Runat="server"
Text="Press Me" />
<br />
Your Name Is: <asp:Label ID="YourName" Runat="server" />
</form>
</body>
</html>
' Ch1CodeBehind.vb
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class Ch1CodeBehind
Inherits System.Web.UI.Page
Public Sub btn_Click(Sender As Object, E As EventArgs)
YourName.Text = Name.Text
End Sub
End Class
Thanks for your help,
Marni
Message #2 by "Peter Lawrence" <peter.lawrence@p...> on Tue, 23 Apr 2002 19:13:31 +0100
|
|
Looks to me like they missed out a couple of lines. In the VB file the class
needs to know about the controls on the page (in the aspx file). So add the
following within the class and you should be OK...
Public YourName As Label
Public Name As TextBox
Peter
----- Original Message -----
From: "Marni Alvarez" <marni@f...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Tuesday, April 23, 2002 6:05 PM
Subject: [aspx_beginners] Code Behind
> MessageHi there.
>
> I am reading the book Professional ASP.NET version 1.0 and am trying to do
> the code behind example on pages 29-30. But I am getting the following
> error:
> Compiler Error Message: BC30451: Name 'YourName' is not declared.
>
Message #3 by "Dmitry Brook" <brook74@h...> on Tue, 23 Apr 2002 20:02:00 +0000
|
|
Looks like 'YourName' is not a valid name of control... check this name -
maybe you yse ordinary HTML control instead of WEB Server Control ? In that
case it will be also anavalible.
Cheers.
>From: "Marni Alvarez" <marni@f...>
>Reply-To: "aspx_beginners" <aspx_beginners@p...>
>To: "aspx_beginners" <aspx_beginners@p...>
>Subject: [aspx_beginners] Code Behind
>Date: Tue, 23 Apr 2002 10:05:55 -0700
>
>MessageHi there.
>
>I am reading the book Professional ASP.NET version 1.0 and am trying to do
>the code behind example on pages 29-30. But I am getting the following
>error:
>Compiler Error Message: BC30451: Name 'YourName' is not declared.
>
>I tried adding the Name="YourName" property, but that didn't work either.
>The code is right from the book. Any ideas?
>
>' TestASPX.aspx
> <@Page Language="VB" Inherits="Ch1CodeBehind"
>Src="Components\Ch1CodeBehind.vb" %>
><html>
> <body>
> <form runat="server">
> Enter Your Name: <asp:TextBox ID="Name" Runat="server" />
> <br />
> Press Button: <asp:Button OnClick="btn_Click" Runat="server"
>Text="Press Me" />
> <br />
> Your Name Is: <asp:Label ID="YourName" Runat="server" />
> </form>
> </body>
></html>
>
>' Ch1CodeBehind.vb
>Imports System
>Imports System.Web.UI
>Imports System.Web.UI.WebControls
>
>Public Class Ch1CodeBehind
> Inherits System.Web.UI.Page
> Public Sub btn_Click(Sender As Object, E As EventArgs)
> YourName.Text = Name.Text
> End Sub
>End Class
>
>Thanks for your help,
>Marni
>
>
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
Message #4 by "Marni Alvarez" <marni@f...> on Tue, 23 Apr 2002 15:41:05 -0700
|
|
Yes, this worked. Thanks!
----- Original Message -----
From: "Peter Lawrence" <peter.lawrence@p...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Tuesday, April 23, 2002 11:13 AM
Subject: [aspx_beginners] Re: Code Behind
> Looks to me like they missed out a couple of lines. In the VB file the
class
> needs to know about the controls on the page (in the aspx file). So add
the
> following within the class and you should be OK...
>
> Public YourName As Label
> Public Name As TextBox
>
> Peter
>
>
> ----- Original Message -----
> From: "Marni Alvarez" <marni@f...>
> To: "aspx_beginners" <aspx_beginners@p...>
> Sent: Tuesday, April 23, 2002 6:05 PM
> Subject: [aspx_beginners] Code Behind
>
>
> > MessageHi there.
> >
> > I am reading the book Professional ASP.NET version 1.0 and am trying to
do
> > the code behind example on pages 29-30. But I am getting the following
> > error:
> > Compiler Error Message: BC30451: Name 'YourName' is not declared.
> >
>
>
>
|
|
 |