View Full Version : Button not appearing
steveg
04-09-2003, 01:53 PM
Right ive just been handed a new project that my manager wants writing in ASP.net
The problem is is that Ive never used .net before and have no idea what is going on properly.
My problem is this -
following the instructions in a book I'm trying to get my "hello world" web form to run. All it is is a webform with a button on it that when you click it it displays hello world on the browser.
Simple ? well I would of thought so but when I run my web form the button is not appearing, if I put a label on it, that appears but no button ???
I'm not getting an error message or anything and the buttons visibility is set to true, this book is about as much use as an ashtray on a motorbike. Mind you it is Microsoft Press.
Any idea's ?
Thanks in advance
Steve.
david7777
04-09-2003, 02:33 PM
Post the code and ill see if i can help you out...
Also check what version of the .net framework you have and let me know.
steveg
04-09-2003, 02:42 PM
Here's the code below. Im working on version 1.0
I've followed the book to the letter but its just not working.
Thanks
****************************************************
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#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
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Write("Hello World!<BR>")
End Sub
End Class
david7777
04-09-2003, 03:41 PM
Firstly, version 1.1 is out and better. Possibly not the cause of you problem, but there is a chance.
I cant say I have coded in this way before, but here is a way that works for me:
<%@ Page Language="VB" %>
<script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
Label1.text = "Hello World!"
TextBox1.text = "Hello World!"
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:Label id="Label1" runat="server">...</asp:Label>
<br />
<asp:TextBox id="TextBox1" runat="server">...</asp:TextBox>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Start"></asp:Button>
</p>
</form>
</body>
</html>
That definately works, and is much easier to understand...
:cool:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.