I know that I can call a page method with jquery using the following syntax
$.ajax({ type: "POST", url: "Default.aspx/GetDate", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { // Replace the div's content with the page method's return. $("#Result").text(msg.d); } });
This works for aspx pages but is it possible with ascx pages? (web controls)
I've been trying it for about half an hour and since I can't get it to work I'm wondering if it's even possible.
Note: Just to be clear, when I try to call the ascx page I am updating the url in jquery :)
No, because ascx controls don't represent a real URL that can be accessed from a client machine. They're purely server-side meant to embed in other pages.
What you might want to do is just have an aspx page that provides the same snippet of html you currently have in your ascx file. An aspx page doesn't necessarily need to provide a full html document (<html><body> etc.), it can just render the user control you're interested in.
We use this technique all the time with the ingrid plugin, which requires a callback url for the table contents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With