-
No buttons
Hi,
just fiddling at "Hello World" stage. With .NET professional installed on a Win2000 professional machine, when I try creating and running a simple asp.net app with one button on it and labels - all I get is the labels on the subsequent web page through IE.
Can anyone explain and help me please - where has the button gone?
Cheers.
-
If you could post the source of the page your missing the button im sure we can figure it out for you.
-
a Web Form button? As in
<asp:Button blah blah>
??
If so...does it have the runat="server" attribute in it? If it doesnt that would keep the button fropm showing.
-
haven't done enough experimenting myself to see if it needs the />, but it might.... just try somethin like this:
<asp:Button
id="Blah"
Text="MyButton"
OnClick="NameofSubHere"
Runat="Server" />
that will make a button with an id of blah (so u can do stuff like Blah.Visible = False), and the button will read MyButton, and when you click it, it will call NameofSubHere.
Runat="Server" kinda turns it into a .net button..
also, i think it helps to have that button in a form tag :)
so really you'd have somethin like:
<form Runat="Server">
<asp:Button
id="Blah"
Text="MyButton"
OnClick="NameofSubHere"
Runat="Server" />
</form>
try that out.
-
well you always need to close a tag anyway..whether this is forced by ASP .NET, I dont know, but it should always be done anyway
Also the button does not HAVE to be ina form tag...only if you want it to do something..:P
The button should still appear regardless.
-
true..
you're not getting any errors on the page in the browser?
-
well he said that just the button does not show but the labels do..that is why I said he may be missing the runat="server" as without it, there wont be any error, it will be sent to the browser as is but the browser wont recognize the <asp:button...>
and wont do anything with it.
-
the code
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebAppTest.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 214px; POSITION: absolute; TOP: 155px" runat="server" Text="Button" Width="125px" Height="54px" BackColor="Red" BorderStyle="Groove" ForeColor="Black"></asp:Button>
</form>
</body>
</HTML>
-
Using beta 2 code the following shows a button(with your style), click the button and hello world gets stamped where the label control is located(all asp.net tags must be closed properly, the compiler will let you know in detail if they're not):
Code:
<script language="vb" runat="server">
Sub myButton_OnClick(s As Object, e As EventArgs)
myLabel.Text = "<p>Hello World!</p>"
End Sub
</script>
<html>
<head>
<title></title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:Button id="myButton"
style="Z-INDEX: 101; LEFT: 214px; POSITION: absolute; TOP: 155px"
runat="server"
Text="Button"
Width="125px"
Height="54px"
BackColor="Red"
BorderStyle="Groove"
OnClick="myButton_OnClick"
ForeColor="Black"/>
<asp:Label Runat="server"
id="myLabel"/>
</form>
</body>
</html>
-
Solved!!!
Just for other people who may suffer same problem:
I found out that ASP.NET won't work if you install the .NET framework before you install IIS - like I did. In the help there is a command line instruction which repairs this. However, I had tried this before but didn't notice a syntax error in the instruction (there is an extra space in the command) but I think I didn't get any indication that it had not performed. Anyway all is well now - I think!
-
God damn XHTML/.net...
<topic breaker: DO NOT BOTHER READING IF YOU WANT TO STICK TO THE TOPIC...>
Don't know about you people, but I find the idea of having to type in, for example, "value='value'", a bit stupid, when there is a default in normal HTML... XHTML has some crazy syntax rules...
Jus' gettin' that of my chest - it's kinda the wrong place though lol... Nevermind - sorry folks...
P.S: I don't really like "<br />" either - standard "<br>" works just fine, etc! ARGH...