In a web application asp.net c# 2003 project that consists of master page and other **pages **as follows:

Currently the project is using a home page full of icons that user click one and then goes to the related page. To come back user has to click on home link, or use bread crumbs links.

Now I want to change it so that in master page a fixed panel show all menus, grouped, and rest space on master page to be used for a Place Holder (like a div) and be filled with dynamic selected **htmls **codes for the pages that user clicked.

I have changed UI so that menu is filled and ready to use, when user click on any menu:

There is 2 possibility:

1- Using Post back, page is sent back to server, then master page, menus and requested page render and result come back to use.

2- A javascript function is called to load requested aspx page from the server.

The first one works fine.

But as the second one is preferred, I tried it and faced problems.

Using Javascript

When calling an asp.net page, server renders the page and master page together and send result back to user, while on my page I have master page and menus and I just needed the requested page to be rendered on server ( since it contains language resources and jobs to be done ) and the result as html come back and inject to a div on page.

Question: I have tried all of these:

1- How to call an aspx page and force server to ignore master page and send back just rendered page html?

2- Or how to call server and use a ascx user control to run and render aspx page and send resulted html back?

3- Or how to call a **ashx ** page and code it to call the aspx page to render without master page?

I have tried all of them and failed, page come back without master page but it is not rendered or page and master pare rendered together.

Now I use an empty master page and the project is working, but in middle of my page there is another html>body> element that is very unpleasant.

Conversion or upgrade is not possible.

Jquery calling page:

function setPartialPage(address){
    //var url = Host + '/Default.ashx';
    var url = Host + address.replace('~', '');
    console.log(url);
    
    // Ajax that call server - Works fine.
    getResult('{"IdFunction":"' + address + '"}',
        url,
        showResult
    );
}
function showResult(data) {
    if (data === "undefined" || data === "404" || data === "404," || data.length === 0) {
        showMessage(data.replace('404,', '').replace('404', ''), 'red', 'Page not loaded!');
    } else {
        $("#app").html(data)
    }
}

Default.ashx.cs file:

using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

namespace Trade
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Default : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var masirPage = context.Request.Form["IdFunction"] as string;
            context.Response.WriteFile(masirPage);
            //context.Response.WriteFile(masirPage.Replace(".aspx", ".ascx"));
            //context.Response.WriteFile("~/App_Main/User/Request/Tavoni/Default.ascx");
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
0

There are 0 best solutions below