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 6992387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:37:41+00:00 2026-05-27T19:37:41+00:00

I am creating a master page for admin-side of my application, which is using

  • 0

I am creating a master page for admin-side of my application, which is using asp.net 4.0 framework and webforms. I have different user controls for sidemenu in different pages. I need to determine which user control is to be loaded at runtime only. I thought of using jquery ajax for this. Can anyone help me on this?
I tried the following jquery but this is alert ‘error occured’

 $(document).ready(function () {
    alert("Ready");
    // $(".admin_side_menu").load("Shared/AdminManageDataSideMenu.ascx");

    $.ajax({
        type: "POST",
        url: "Shared/AdminManageDataSideMenu.ascx",
        contentType: "application/html; charset=utf-8",
        dataType: "html",
        success: function (data) {
            // var object = JSON.parse(data);
            alert("success" + data);
            (".admin_side_menu").append(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            debugger;
            alert("Error Occured!");
        }
    });

});
  • 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-27T19:37:41+00:00Added an answer on May 27, 2026 at 7:37 pm

    you will need to make an ashx handler that will return you the user control like

    public class FooHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            context.Response.Write(RenderPartialToString("AdminManageDataSideMenu.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;
            }
        }
    }
    

    now you can call the handler via jquery like

    $.ajax({
            type: "POST",
            url: "Foo.ashx",
            contentType: "application/html; charset=utf-8",
            dataType: "html",
            success: function (data) {               
                alert("success" + data);
                $(".admin_side_menu").append(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                debugger;
                alert("Error Occured!");
            }
        });
    

    Reference: https://stackoverflow.com/a/4597341/413670

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC application I'm building and I'm using a Master page.
I have a asp.net web application and I create a master page when i
I have an asp.net content page which is used inside of a master page
In my ASP.NET app I have a control in the master page that raises
So I have this idea of creating a asp.net user control, to handle all
I'm creating a custom master page for a MOSS publishing site. The designers have
Background: I work in a suite of ASP.NET applications that have several different modules.
I want to develop a web application with a master page containing an <asp:Xml
Is it possible to create nested master pages in an ASP.NET Web Application projects
I am implementing Javascript Validation on an ASP.Net page that is inside a Master

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.