Jul 05, 2023, 8:26 PM
ResourceManager confusion upgrading to 5.3 from 1.7
-- Oops, I posted this in the wrong thread -- moving it to 5.x classic help thread. my apologies.
In Ext.Net 1.7 we defined a ResourceManager in the master page because we needed to load some js resources in that master page. Then, in child pages we would use the ResourceManagerProxy to load js resouces needed by that child page. In 5.3 the ResourceManagerProxy is no longer used. So, in the child pages I attempt to use ResourceManager.GetInstance() in order to get the ResourceManager and then use it to load the js resources, trouble is that ResourceManager.GetInstance() returns null.
It's worth noting, I tried to just use ResourceManager in the child page but then I get an error that ResourceManager can only be used once per page.
Here is what I'm trying to do:
In the master page:
Then, in a child page, I need to load some resources but I cannot get a handle on the ResourceManager. I've tried everything I could find, but it always turns out to be null.
Maybe this is unconventional or uncommon, but it is how this system was written. Ultimately I need to use the ResourceManager in the master and in child pages and looking for the best approach.
In Ext.Net 1.7 we defined a ResourceManager in the master page because we needed to load some js resources in that master page. Then, in child pages we would use the ResourceManagerProxy to load js resouces needed by that child page. In 5.3 the ResourceManagerProxy is no longer used. So, in the child pages I attempt to use ResourceManager.GetInstance() in order to get the ResourceManager and then use it to load the js resources, trouble is that ResourceManager.GetInstance() returns null.
It's worth noting, I tried to just use ResourceManager in the child page but then I get an error that ResourceManager can only be used once per page.
Here is what I'm trying to do:
In the master page:
<body>
<ext:ResourceManager runat="server" ID="BLResourceManager"/>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
BLResourceManager.RegisterClientScriptInclude("scripts-common", ResolveUrl("~/Scripts/Common/common.js"));
}
</script>
The above is just a snippet to give an idea of what is going on, it loads the common.js just fineThen, in a child page, I need to load some resources but I cannot get a handle on the ResourceManager. I've tried everything I could find, but it always turns out to be null.
Maybe this is unconventional or uncommon, but it is how this system was written. Ultimately I need to use the ResourceManager in the master and in child pages and looking for the best approach.
<%@ Page Title="Login" Language="C#" MasterPageFile="~/Views/Shared/ExtBorderLayout.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="ContentMain" ContentPlaceHolderID="MainContent" runat="server">
<Script runat="server" type="text/C#">
protected void Page_Load(object sender, EventArgs e)
{
var rm = ResourceManager.GetInstance();
// rm is null here, and I just don't understand how to get the ResourceManager in the child page
rm.RegisterClientScriptInclude("scripts-child-script", ResolveUrl("~/Scripts/child-script.js"));
}
</Script>
Last edited by bryanparke; Jul 06, 2023 at 12:39 PM.