sherinpoulose 0 Light Poster

I have a class which has the method to print output.In that,i am using mobile control label.below is the code

public Label Label1;
public LiteralText literalList;
public void printNode(TreeNode root, string tabs)
{



Label1.Text = tabs + '|' + root.attribute + '|' + ':';



StringBuilder sb = new StringBuilder();
if (root.attribute.values != null)
{

for (int i = 0; i < root.attribute.values.Length; i++)
{
sb.Append(tabs + "\t" + "<" + root.attribute.values[i] + ">");

root.attribute.values[i] + ">");

TreeNode childNode = root.getChildByBranchName(root.attribute.values[i]);
printNode(childNode, "\t" + tabs);
}
}
literalList.Text = sb.ToString();
}

I created an instance of this label and literal in a webpage like this;

dectreeid3.Label1= new System.Web.UI.MobileControls.Label();

dectreeid3.literalList = new System.Web.UI.MobileControls.LiteralText();

here dectreeid3 is an instance of that particular class.
when i am running,it is giving error as 'Object reference not set to an instance of an object.' at this code line 'Label1.Text = tabs + '|' + root.attribute + '|' + ':';

what may be the problem,how can i correct it?
Is there any other way to display the output in a web page

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.