vb.net wed application on winXP Home and Cassini

A

Alice Z.

Hi,

I have created a very simple web page using vb.net. Unfortunately, it
seems my vs.net can not generate correct HTML code based on my vb code
(it doesn’t handle the load and click event). The vb code and related
HTML code are as follows:

.net generated Vb code:
Public Class Hello
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "
...
#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
TextBox1.Text = "Type your name"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Label1.Text = "hello, " & TextBox1.Text & "!"
TextBox1.Visible = False
Button1.Visible = False
End Sub
End Class

.net generated HTML code:
<HTML>

<body>
<form id = “Form1” method = “post” runat = “server”>
<asp: Label id = “Label1” runat = “server”>Enter a name</asp:
Label>
<asp:TextBox id==“TextBox1” runat=“server’></asp:TextBox>
<asp:Button id=“Botton1” runat=“server”></asp:Button>
</form>
</body>
</HTML>

Could anyone tell me where is wrong?

Thanks

Alice
 
D

Dino Chiesa [Microsoft]

There are a bunch of smallish typos.
This worked for me.

-Dino
Microsoft
=====================================================
<%@ Page Language="VB" Debug="true" Trace="false" %>

<script runat="server">
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 'Handles MyBase.Load
'Put user code to initialize the page here
Trace.Write("Page_Load")
if (TextBox1.Text="")
TextBox1.Text = "Type your name"
end if
End Sub

Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) 'Handles Button1.Click
Label1.Text = "hello, " & TextBox1.Text & "!"
TextBox1.Visible = False
Button1.Visible = False
End Sub

</script>

<HTML>
<body>
<form id = "Form1" method = "post" runat = "server">
<asp:Label id = "Label1" runat = "server">Enter a name</asp:Label>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" OnClick="Button1_Click"
Text="ClickMe"></asp:Button>
</form>
</body>
</HTML>
 

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

Top