Hi Aderson Oliveira,
I normally use this code snippet to insert a ascx file with controlKey file into the default view ascx file.
This way I can use the view skin on the ascx files with controlKey.
I was just wondering if there is a method similar to this on MVC/SPA templates.
protected void GetModule()
{
try
{
//Get the control key passed in by the query string
//if no key is present load the default view control
string controlKey;
if (Request.Params["cid"] == null)
controlKey = "QuizForm";
else
controlKey = Request.Params["cid"];
//Get the module path and load the control
string mPath = getModulePath(ModuleId, TabId, controlKey);
var objModule = (PortalModuleBase)this.LoadControl(mPath);
objModule.ModuleConfiguration = this.ModuleConfiguration;
//When you load a control in a control you lose the path to the the resource
//file so need to tell the module which resouce file to use.
objModule.LocalResourceFile = this.LocalResourceFile.Replace("Dispatch", controlKey);
this.Controls.Add(objModule);
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
}
private string getModulePath(int moduleid, int tabid, string controlKey)
{
string path = String.Empty;
try
{
//step 1. get the moduledefid based on the moduleid and tabid
ModuleController mc = new ModuleController();
ModuleControlController mcc = new ModuleControlController();
ModuleInfo mi = mc.GetModule(moduleid, tabid);
if (mi != null)
{
//step 2. using the moduledefid get the module control records
var mControl = ModuleControlController.GetModuleControlByControlKey(controlKey, mi.ModuleDefID);
if (mControl != null)
path = "~/" + mControl.ControlSrc;
}
}
catch (Exception ex)
{
Exceptions.ProcessModuleLoadException(this, ex);
}
return path;
}