Webform in book won't work live, what's up?

J

Jozef

Hello,

I'm doing the lessons out of a Sams ASP.net book and have copied the
following verbatim, out of the book (without the beginning and ending
quotes);

"'<%@ Page Language="vb"%>
<%@register TagPrefix="TYASPNET" TagName=LoginForm src=LoginForm.ascx%>
<script runat=server>
Sub Page_Load(obj as object,e as eventargs)
lblMessage.Text = "Properties of the user " & _
"control:<br> " & _
"id: " & LoginForm1.id & "<br>" & _
"BackColor: " & LoginForm1.Backcolor & "<br>" & _
"Username: " & LoginForm1.Username & "<br>" & _
"Password: " & LoginForm1.Password
End Sub"

The lblMessage control is part of the LoginForm user control.

I've reviewed the code in the book and can't figure out what's wrong.

I'll cut and paste both pages of code in their entirety below.

Thanks!
Jo
"<script language=vb runat=server>
Public Backcolor as string="white"
public UserName as string
Public Password as string

LoginForm.ascx = the following;

"Public Sub Submit(obj as object, e as eventargs)
lblMessage.Text="Username: <b>" & User.Text & _
"</b><br>" & "Password: <b>" & Pass.Text & "</b><p>"
End Sub
</script>

<table style="background-color:<%=backcolor%>;
font: 10pt verdana;border-width:1;
border-style:solid;border-color:black;"
cellspacing=15>
<tr>
<td><b>Login: </b></td>
<td><asp:Textbox id=user runat=server /></td>
</tr>
<tr>
<td><b>Password:</b></td>
<td><asp:textbox id=Pass TextMode=Password runat=server /></td>
</tr>
<tr><td></td>
<td><asp:button text=Submit runat=server OnClick=Submit /></td>
</tr>
</table>
<p>
<asp:Label id=lblMessage runat=server /></p>"

LoginMaster.aspx = the following

<%@ Page Language="vb"%>
<%@register TagPrefix="TYASPNET" TagName=LoginForm src=LoginForm.ascx%>
<script runat=server>
Sub Page_Load(obj as object,e as eventargs)
lblMessage.Text = "Properties of the user " & _
"control:<br> " & _
"id: " & LoginForm1.id & "<br>" & _
"BackColor: " & LoginForm1.Backcolor & "<br>" & _
"Username: " & LoginForm1.Username & "<br>" & _
"Password: " & LoginForm1.Password
End Sub
</script>
<html>
<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">
<tyaspnet:LoginForm id=LoginForm1 runat=server
password=MyPassword
UserName=Chris
BackColor=Beige/>
</form>

</body>
</html>
 
J

Jozef

Woops! Sorry, thanks for pointing that out. Here is the error;
Compiler Error Message: BC30451: Name 'lblMessage' is not declared.

Source Error:


Line 3: <script runat=server>
Line 4: Sub Page_Load(obj as object,e as eventargs)
Line 5: lblMessage.Text = "Properties of the user " & _
Line 6: "control:<br> " & _
Line 7: "id: " & LoginForm1.id & "<br>" & _


Jo
 
T

Terry Burns

You probably forgot to change the name of the label to lblMessage. To do
this open your web form in designer and select the label, in the properties
for this control, go to the ID and make sure its lblMessage ( 1's can look
just like l's ( L's ) ) you didnt use a 1 did you >?

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top