Accessing ascx file from desktop application

G

Guest

Hello

I am trying to write a #C windows desktop application that loads an ascx file contents (user control) from file, initiates it and then registers to database everything it finds. I tried that way:

1 Page page=new Page();
2 Control control=page.LoadControl(virtualPath);
3 string debug = control.ID;

but I got NullReferenceException on the 2nd line.

From earlier post http://www.dotnet247.com/247reference/msgs/29/148858.aspx
I found out that to create a control dynamically, one first needs to include className into the ascx and to register the control in page. My brand new dynamically created page object of course lacks that registration and I guess that's why the LoadControl method does not work.

Is anybody able to explain, how to properly look up the contents of an ascx file?

I would appreciate if you sent all answers directly to (e-mail address removed) as well.

Thanks in advance,

Kristjan
 
J

John Saunders

Kristjan Sander said:
Hello

I am trying to write a #C windows desktop application that loads an ascx
file contents (user control) from file, initiates it and then registers to
database everything it finds. I tried that way:

I'm afraid that what you want to do doesn't make much sense. An .ascx file
is just a text file. It only has meaning when it's processed by something
like ASP.NET. Even then, it has no independent meaning, but rather it only
has meaning in the context of an existing page.

It is possible to host ASP.NET within a Windows program, but I'm not sure
that's what you want to do. In fact, I'm not at all sure why you want to do
this. Perhaps if you could tell us what you'd like to accomplish, we'd be
able to give better advice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top