Possible to load ASCX with jQuery.load() function?
Asked Answered
O

6

0

Is it possible without encapsulating these controls in aspx files? The Register tag makes me think that it is not.

Oarlock answered 31/7, 2009 at 13:46 Comment(0)
C
2

You can't call ascx page directly, they can't serve any html without added to aspx or render then dynamically in response to any page/handler.

Countryandwestern answered 31/7, 2009 at 13:51 Comment(0)
V
2

One possible way would be to have a generic aspx stub page that acts as a host to the ascx in the normal web forms way make a callback to the that page using JQuery's $.ajax() method with some arguments to denote what ascx control you want to load.

Then on your stub / host page, override the render method and render the control directly to the output stream using response.output.write. The callback handler on the client will catch the output and then it can be inserted into the DOM in the normal way or using using the version of $.load() that allows the specification of a DOM element.

hope this helps.

Viaduct answered 20/12, 2010 at 21:29 Comment(0)
I
0

Since I've started using jQuery/Ajax more and more, I find I've been using server controls less and less.

Things that I used to put into controls are now just individual aspx pages which get loaded into panels.

If you have old ASCX files, it shouldn't be too hard to convert them to ASPX

Incarcerate answered 31/7, 2009 at 13:59 Comment(0)
M
0

No.

That said, you could place your ascx inside an UpdatePanel and set the panel's content visible/invisible using the standard Asp.Net postback mechanisms.

Or you could write a separate IHttpHandler which generates HTML code that your Javascript code adds to the page using DOM. This part of the page would however not be accessible in PostBack.

Menses answered 31/7, 2009 at 14:0 Comment(0)
E
-1

No, ASCX are user-controls, that exist on ASPX. You will need to make it a Page, or convert into Handler.

Exemplification answered 31/7, 2009 at 13:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.