Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3635748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:56:36+00:00 2026-05-19T00:56:36+00:00

Is there a way to load ascx file by jQuery? UPDATE : thanks to

  • 0

Is there a way to load ascx file by jQuery?

UPDATE:

thanks to @Emmett and @Yads. I’m using a handler with the following jQuery ajax code:

 jQuery.ajax({
    type: "POST",  //GET
    url: "Foo.ashx",
    data: '{}',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (response)
    {
        jQuery('#controlload').append(response.d); // or response
    },
    error: function ()
    {
        jQuery('#controlload').append('error');
    }
 });

but I get an error. Is my code wrong?

Another Update :
I am using

error: function (xhr, ajaxOptions, thrownError)
{
    jQuery('#controlload').append(thrownError);
}

and this is what i get :

Invalid JSON:
Test =>(this test is label inside my ascx)

and my ascx file after Error!!!

Another Update :

my ascx file is somthing like this:

<asp:DropDownList ID="ddl" runat="server" AutoPostBack="true">
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label1" runat="server">Test</asp:Label>

but when calling ajax i get this error in asp: 🙁

Control ‘ctl00_ddl’ of type ‘DropDownList’ must be placed inside a form tag with runat=server.

thanks to @Yads. but his solution only work with html tag.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T00:56:37+00:00Added an answer on May 19, 2026 at 12:56 am

    Building off Emmett’s solution

    public class FooHandler : IHttpHandler
    {
    
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            context.Response.Write(RenderPartialToString("Foo.ascx"));
        }
    
        private string RenderPartialToString(string controlName)
        {
            Page page = new Page();
            Control control = page.LoadControl(controlName);
            page.Controls.Add(control);
    
            StringWriter writer = new StringWriter();
            HttpContext.Current.Server.Execute(page, writer, false);
    
            return writer.ToString();
        }
    
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
    

    Use the following jquery request

    jQuery.ajax({
        type: "POST",  //GET
        url: "Foo.ashx",
        dataType: "html",
        success: function (response)
        {
            jQuery('#controlload').append(response); // or response
        },
        error: function ()
        {
            jQuery('#controlload').append('error');
        }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is There a way to load swf file via jQuery Ajax Or after the
Is there any way to load a local file using an html document that
Using jquery what is the best way to load a snippet of code for
Is there any way to load a swf file and display it in a
Is there a way to load and run an EXE file on the client
Is there a way to load external CSS files, like we load JS file
Is there a way to load the content of a file to TAdvMemo not
Is there any way to load a text file (edi, efi file) into a
Is there any way to load a jar file BEFORE a system jar? I
I'm using a service from my OnApplicationStarted inside my Global.ascx.cs file. Is there a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.