ASCX without INamingContainer

  • Thread starter Thread starter Natan
  • Start date Start date
N

Natan

Is there any possibility to make an ASCX be loaded in an object that
does not implement INamingContainer, but mantain the funcionality of
events and etc?

I know i can`t do this using the current Page functions, but if I
implement another handler, or create another kind of UserControl that
doesn`t implement INamingContainer and a function that does what
LoadControl does... don`t know.

Just want to know if there is any way to do this.

Thanks.
 
You could always write a method that would just spit out HTML, or read
an HTML fragment from a file on disk and spit it into the page.
 
Scott said:
You could always write a method that would just spit out HTML, or read
an HTML fragment from a file on disk and spit it into the page.

For that i could use #include, or even user controls....
What i need is an user control that doesn't extend INamingContainer. It
must be a compiled control to keep all the code, events and methods.
 
User controls in ASP.NET do implement INamingContainer, I thought you
were trying to avoid INamingContainer. What are you trying to
accomplish ultimately - avoid the client side ID munging?
 
Scott said:
I thought you were trying to avoid INamingContainer.

Yes. That's what i said.
What are you trying to accomplish ultimately - avoid the client side ID munging?

Exactly what i told before... A way to load a page or user control
inside another without the mess INamingContainer creates, but retaining
the functionality of a user control, events and code.

I have been searching throught mono's source code but it goes through
some internal classes. Probably .NET does the same to compile the control...

I wish there was a way to tell ASP.NET to do nothing with
INamingContainer...
 
I'm trying to be helpful, but you are not telling me what the "mess"
is that INamingContainer creates.
 
Scott said:
I'm trying to be helpful, but you are not telling me what the "mess"
is that INamingContainer creates.

The problem for me is exactly what INamingContainer does... it keeps IDs
unique by prefixing them with the container name. And I know what it
does, but see, I don't want to load "user controls". For user controls,
it`s ok...

What i asked for is a way to load ASCX files to a control that doesn`t
implement INamingContainer. Even if i need to reimplement the ASP
parser... i just want to know what i could do to achieve this.
 
Perhaps you could derive from System.Web.UI.Control and implement
ITemplate, although I can't think of any examples on the web doing
this.

What you'll see happen in this case generally is that if there is
Javascript that needs to know the client ID, the script is formatted
server side eith the ClientID property of the control (or write the
ClientIDs into an array for javascript to reference).
 
Scott said:
Perhaps you could derive from System.Web.UI.Control and implement
ITemplate, although I can't think of any examples on the web doing
this.

What you'll see happen in this case generally is that if there is
Javascript that needs to know the client ID, the script is formatted
server side eith the ClientID property of the control (or write the
ClientIDs into an array for javascript to reference).

I repeat: i`m not trying to use UserControls... i`m trying to do some
experiences and see what i can do with asp.net. it`s not an usual use of
ascx files.

That`s the reason i said i could reimplement the whole asp.net parser if
i need. I just want to know what i can do to load an ascx file and make
it work, but not through user controls.
 
Natan:

I didn't mention user controls in the last post.

I did mention the Control class from the System.Web.UI namepace. This
is the base class defining the members common to all server side
ASP.NET controls, including (but not limited to) user controls, data
bound controls, literal controls, etc. In other words, if you want to
implement something new and interesting, this is as close to "starting
from scratch" as you'll get.

In a class derived from Control you can overide the Render method and
have complete control over the HTML it produces. You'd have to
implement your own Load method, as LoadControl is not a virtual
function, and the classes to parse and compile ASCX files are
internal.
 
Scott said:
In a class derived from Control you can overide the Render method and
have complete control over the HTML it produces. You'd have to
implement your own Load method, as LoadControl is not a virtual
function, and the classes to parse and compile ASCX files are
internal.

thanks... that's what i imagined. =/
after seeing how asp pages are parsed and that there is a lot of
internal classes in System.Web, i think it will bee too complicated to
reimplement it.

I think i'll try Mono instead, so I can modify the necessary sources to
make this work.

Thanks.
 

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

Back
Top