[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Create a page instance variable

Posted on 2009-04-29
4
Medium Priority
?
956 Views
Last Modified: 2012-05-06
I'm trying to create and manipulate a page variable.

e.g. I have a page called Default:

Default myPage = new Default();

this compiles and runs ok, but all the controls within the myPage variable are null, I want to instantiate the page fully.
I've tried calling RenderControl on it but it hasn't made any difference and I just get an empty string as the output.

Any ideas how I could go about this?
0
Comment
Question by:NazoUK
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24261422
Where does your page variables are set?  If they are not set in the constructor, its normal that they are Null.   Why do you want to instantiate a page without showing it exactly?

P.S: Any code would be appreciated

0
 
LVL 6

Expert Comment

by:ViceroyFizzlebottom
ID: 24262680
Are you creating the page manually at runtime, or are you using the Visual Studio design surface?

If you're doing it manually, then you have to do all the grunt work manually as far as declaring the controls and their positions, attributes and values. That's why the design surface is so handy when creating pages. All that work is done for you behind-the-scenes.

0
 
LVL 15

Author Comment

by:NazoUK
ID: 24263299
The page in question has some Web Parts and a Web Part manager.
What I'm trying to do is to create an instance of that page inside a web service, and then use the Web Part manager on the page to move the web parts around.

When I step through in the debugger and examine the myPage variable I can see the Web Part Manager and other controls in there, but they are all null.

I'm just experimenting at the moment and this is probably a  dead end anyway but I thought I'd see if anyone had done anything similar.
0
 
LVL 15

Accepted Solution

by:
NazoUK earned 0 total points
ID: 24268509
Not such a dead-end after all: I found a blog post that shows how to do it, for the same scenario I'm trying to do:

http://blogs.msdn.com/mharder/archive/2006/12/11/pdc-2005-slides-and-code.aspx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month19 days, 19 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question