Thursday, March 22, 2012

Object reference not set to an instance of an object HELP!

i get this server error when i try to run httpwriter. Can anyone help? i'm trying to run a string of html codings to open in current/new window. Not sure if this is able to work though..

Object reference not set to an instance of an object

Line 151: HTP.Write(x);

C# file

part of CODE:

publicclass test2 : System.Web.UI.Page

{

protected System.Web.UI.WebControls.Button BTNClick;

protectedSystem.Web.HttpWriter Writer;

}

...

privatevoid BTNClick_Click(object sender, System.EventArgs e)

{

string x =@dotnet.itags.org."...ssssss"

Writer.write(x);

}

...

i get this error sometimes when i do not create an instance from the class for example

Dim a as ClassName()

a.print()

this is where i have problem!!!

but if you do

Dim a as New ClassName()

a.print()

That will be fine as i have created new instance by saying "New" key word... but notice that this message error is not always mean this !!! so try that and let me know !


This does not create an HttpWriter
protected System.Web.HttpWriter Writer;
It only declares one. In fact, just do this as you've already got an instance of an HttpWriter built into the Page class.

private void BTNClick_Click(object sender, System.EventArgs e)
{
string x=@."...ssssss"

Response.Write(x);
}

NC...

0 comments:

Post a Comment