shrimp rice
shrimp rice

Reputation: 322

.aspx works but .ascx does not... why and how to fix?

I want to put a ASTreeView web control in a custom web control, ASTreeView sample code is like:

<ct:ASTreeView ID="astvMyTree" 
                    runat="server"
                    ...
                    LoadNodesProvider="~/ASTreeViewDemo5.aspx"

                    .../>

LoadNodesProvider is the page ajax called when loading a node...however if I changed the provider to my .ascx file, it does not work:

LoadNodesProvider="~/ASTreeViewDemo5.ascx"

it did not even go through the Page_Load part of the .ascx file Though this might be related with astreeview itself, I'm wondering what the problem could be? anything I can do to fix it? Thanks!

Upvotes: 0

Views: 1160

Answers (4)

Andrew Burgess
Andrew Burgess

Reputation: 5298

If you really, really want to use an ASPX page/ASCX control, then I suppose it would be best to create a blank ASPX page that has one placeholder, and then attach your user control (based on query string parameters or something I guess) to the placeholder to render out the content for your AJAX control

Upvotes: 0

Gary.S
Gary.S

Reputation: 7131

While it isnt entirely clear to me what LoadNodesProvider is supposed to do, if you want to encapsulate some code or run a process via AJAX you have a couple of options. One would be to create a web service (you could use WCF for this) that the AJAX method could call. Another option would be to create an http handler (ASHX extension typically denotes this). Using an ASPX or ASCX for this doesn't make a whole lot of sense to me. Proco and Tomas are correct regarding the ASCX file, these are Usercontrols and are not stand-alone objects.

Upvotes: 1

Porco
Porco

Reputation: 4203

ASPX is a page and ASCX is a usercontrol. You cannot ajax call a control, so you probably want it to be a page with the control on it.

Upvotes: 4

Tomas Voracek
Tomas Voracek

Reputation: 5914

It is because ascx must have a container ie Page. You can't use it same way as Page.

Upvotes: 4

Related Questions