Loading custom controls using jQuery.load ()

I use a clean test page and load user control using jQuery .load() function. The current error I am getting is this:
GET http://localhost:27950/OCDB/test.ascx 403 (Forbidden)

Here is my page code:

 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %> <%@ Register Src="~/test.ascx" TagPrefix="uc1" TagName="test" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>This is a test.</title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.js"></script> <script type="text/javascript" src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#ucPlaceholder').load('test.ascx'); }); </script> </head> <body> <form id="form1" runat="server"> <div id="ucPlaceholder"> </div> </form> </body> </html> 

And my user control code:

 <%@ Control Language="C#" AutoEventWireup="true" CodeFile="test.ascx.cs" Inherits="test" %> <input placeholder="test input"/> 

As you can see, this is super easy. I assume the page does not compile Register . Can someone show me where I'm wrong?

+4
source share
1 answer

I don't think you can directly invoke a user control with jQuery.
But you can take the help of a universal http handler for it.

http://blog.ovesens.net/2008/12/dynamically-loading-asp-net-user-controls-with-jquery/
http://www.codeproject.com/Articles/117475/Load-ASP-Net-User-Control-Dynamically-Using-jQuery

+3
source

All Articles