OK, so I'm tyring to work with some simple stuff in ASP.NET and C# to get the hang of the super super basics, and I'm having trouble finding out how I can get this scope issue to work. At least, I think it's a scope issue! :)
So, here is my Default.aspx presentation markup:
<%@ Page Language="C#" Inherits="project1.Tree" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>project1_test</title>
</head>
<body>
<form runat="server">
<p><asp:label runat="server" id="lblOutput" /></p>
<asp:TextBox ID="txtGrowBy" runat="server" />
<asp:Button id="btnGrow" runat="server" Text="Grow!!!" />
</form>
</body>
</html>
And here is my CodeBehind file:
using System;
using System.Web;
using System.Web.UI;
namespace project1
{
public partial class Tree : System.Web.UI.Page
{
public int height = 0;
public void Grow(int heightToGrow) {
height += heightToGrow;
}
protected void Page_Load(Object Source, EventArgs E)
{
Tree tree1 = new Tree();
string msg = "Let's plant a tree!<br/>";
msg += "I've created a tree with a height of " +
tree1.height + " metres.<br/>";
lblOutput.Text = msg;
}
public virtual void btnGrowClicked (object sender, EventArgs args)
{
txtGrowBy.Text = tree1.heightToGrow;
}
}
}
Now, I believe the issue lies with the fact that I'm not using a getter and sender, but I'm not 100% sure.