Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I want to declare some WebControls on at a global level so I will have access to them and then instantiate them in certain methods. I was just wondering how to do this. When I try to declare them in Page_Init() it doesn't work. Obviously, I"m very new to ASP.NET, so could anyone please explain how to declare globabl variables for a single page? (not in the global.aspx file)
Posted

I know my previous post was unclear, but here is what I actually wanted to do:

 

MyPlaceHolder.Controls.Add(GenerateTextBox());

 

then I would have something like this:

 

TextBox GenerateTextBox

{

TextBox MyTextBox = new TextBox();

 

return MyTextBox;

}

 

 

 

my question is how do I then get and set properties of this text box? I thought that I could declare it at the top of the scope like this:

 

TextBox MyTextBox;

 

Then I could instantiate it in the GenerateTextBox function, but when I try to maipulate properties it tells me that it doesn't point to an instance of an object. Thanks for any additional help!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...