J
Jim H
I coded my first asp form and attempted to display a text message from a component. The static text "Our component
says:" shows on the aspx page, but the text line from the component does not show. No errors are produced.
Can someone get me started down the right path with aspnet?
The two modules are shown below. The solution, less the .dll and .pdb files, can ge grabed at
http://psiprograms.com/Programs/HelloWorld.zip (about 16 Kb).
Thanks, Jim Holloman
----aspx page-------------------------------------------------------------------
<%@ Import Namespace="HelloWorldApp" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="HelloWorldApp.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.1">
<meta name="CODE_LANGUAGE" Content="C#">
<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">
Our component says: < br /> < br />
<asp:Label ID="Labe11" runat="server"></asp:Label>
<!-- Putting the code within the "form" creates a server error indicating that Page_Load()
is already defined -->
<!--
<script language="C#" runat="server">
void Page_Load( Object sender, EventArgs e )
{
HelloWorld oHelloWorld = new HelloWorld();
Labe11.Text = oHelloWorld.SayHello();
}
</script>
-->
</form>
<!-- This code apparently does nothing! -->
<script language="C#" runat="server">
void Page_Load( Object sender, EventArgs e )
{
HelloWorld oHelloWorld = new HelloWorld();
Labe11.Text = oHelloWorld.SayHello();
}
</script>
</body>
</HTML>
----Hello World component-------------------------------------------------------
using System;
namespace HelloWorldApp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class HelloWorld
{
public HelloWorld()
{
// TODO: Add constructor logic here
}
public string SayHello()
{
return "Hello World -- form a C# component developed with the Visual Studio IDE \n\n";
}
}
}
says:" shows on the aspx page, but the text line from the component does not show. No errors are produced.
Can someone get me started down the right path with aspnet?
The two modules are shown below. The solution, less the .dll and .pdb files, can ge grabed at
http://psiprograms.com/Programs/HelloWorld.zip (about 16 Kb).
Thanks, Jim Holloman
----aspx page-------------------------------------------------------------------
<%@ Import Namespace="HelloWorldApp" %>
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="HelloWorldApp.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.1">
<meta name="CODE_LANGUAGE" Content="C#">
<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">
Our component says: < br /> < br />
<asp:Label ID="Labe11" runat="server"></asp:Label>
<!-- Putting the code within the "form" creates a server error indicating that Page_Load()
is already defined -->
<!--
<script language="C#" runat="server">
void Page_Load( Object sender, EventArgs e )
{
HelloWorld oHelloWorld = new HelloWorld();
Labe11.Text = oHelloWorld.SayHello();
}
</script>
-->
</form>
<!-- This code apparently does nothing! -->
<script language="C#" runat="server">
void Page_Load( Object sender, EventArgs e )
{
HelloWorld oHelloWorld = new HelloWorld();
Labe11.Text = oHelloWorld.SayHello();
}
</script>
</body>
</HTML>
----Hello World component-------------------------------------------------------
using System;
namespace HelloWorldApp
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class HelloWorld
{
public HelloWorld()
{
// TODO: Add constructor logic here
}
public string SayHello()
{
return "Hello World -- form a C# component developed with the Visual Studio IDE \n\n";
}
}
}