More Problems with IIS

C

Chris

I was having problems using my local IIS to display asp.net pages, or any
pages for that matter. I actually reinstalled IIS and then uninstalled the
..net framework and reinstalled it. All pages now work including my asp.net
pages sort of....... What I mean is the page now displays without a server
unavailable error (I resolved this by putting asp.net permissions on the
folder containing the aspx pages). However when I point IIS at that folder
and run the page I see the page but it doesn't respond to any events e.g. I
have created a basic web page with a button, which should run a
response.write line of code. This works when I preview it in the Cassini web
server via VS but not IIS. What obvious thing am I doing wrong? :) Regards,
Chris.
 
J

Juan T. Llibre

re:
!> I see the page but it doesn't respond to any events
!> I have created a basic web page with a button, which should run a
!> response.write line of code.

How are you wiring the button ? Can you post the failing code ?

Here's a simple page which tests several events and runs code when a button is pushed:

helloworld.aspx:
-----------------------
<%@ Page Language="VB" EnableViewState="false" trace="true" %>
<script runat="server">
Sub Page_Load(obj as object, e as eventargs)
Trace.Write("Begin PreInit", Now)
Trace.Write("End Render", Now)
End Sub

Sub Button1_Click(sender As Object, e As EventArgs)
Label1.Text = "Hello, " & TextBox1.Text & "! Welcome to a Hello World ASP.NET example."
End Sub
</script>
<html>
<body>
<form runat="server">
<p>
<asp:Label id="Label1" runat="server">Write your name inthe textbox and click the
button.</asp:Label>
</p>
<p>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button">
</asp:Button>
</p>
</form>
</body>
</html>
 
C

Chris

The button doesn't work. The code in on load event does but the button
doesn't?? Weird. Here is the failing code. Bear in mind I have been
reinstalling things (see first post and the one I made a little earlier that
you responded to) so I don't know whether I have inadvertantly done
something. Could there be something in the web.config or machine.config.
Thanks Juan.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:Button ID="Button1" runat="server" Text="Button" /></div>

</form>

</body>

</html>

Partial Class _Default

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click

Response.Write("test")

End Sub

End Class
 
J

Juan T. Llibre

re:
!> The button doesn't work. The code in on load event does but the button
!> doesn't?? Weird. Here is the failing code.

<asp:Button ID="Button1" runat="server" Text="Button" />

Not weird at all. You aren't wiring the OnClick event to the code.

Use :
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
 
M

Mark Rae

The button doesn't work. The code in on load event does but the button
doesn't?? Weird.

Not weird at all - it's doing exactly what you told it to or, rather, it's
not doing what you haven't told it to...

You've forgotten to specify the server-side method to run in response to the
OnClick event...
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" />
 
C

Chris

Than kyou Juan. I was runing the pages without building the site. I even
removed the OnClick="Button1_Click" from my page and it worked. Is this
right? I was under the impression that asp.net does not need to compile the
page if it has a code behind it will do it on the first view of the page. Am
I misunderstanding something? Thanks for the help Juan.
 

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,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top