Hi All,
I have a problem that I am struck on, can you help?
1) I drag labelX onto the page
2) Create a new class 'myClass' which inherits system.web.ui.page
(Outside of the _default class for the page)
3) I now want to change a property of labelX, from a method within
myClass - How can I do this?
I have tried this (Within 'myClass')...
Label lblMess = new Label();
lblMess = (Label)FindControl("lblMessage");
lblMess.Text = "Hello Again World";
...which results in this error:
"Object reference not set to an instance of an object"
I know this means I am trying to access a null object, but really not
sure what to do to fix this?
I did think perhaps my method in 'myClass' needs to accept a byref
parameter type matching the control, is there another way? I'm sure I
am missing something simple here!
Thanks!!
Simon.
SMiGL - 10 Dec 2007 07:57 GMT
> I have a problem that I am struck on, can you help?
>
[quoted text clipped - 12 lines]
> ...which results in this error:
> "Object reference not set to an instance of an object"
Perhaps 'myClass' not tie with you aspx page and so you can`t find
label.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="'<Name you
file>.aspx.cs"
Inherits="<Class name>" Title="Untitled Page" %>