Hi,
I know this is covered in bits around this Forum and through that I think I am close to solving this - but I am not quite there!
I have:
Events.ascx - this control will just have a place holder which will load the other controls depending on the querystring.
ViewEvent.ascx - this control simply displays the detail of the event.
EditEvent.ascx - this control will be used to create and edit events, depending on the querystring. It is registered twice in the module definition. Once with a control key of createevent, the other, editeven.t
<code>
In my Events.ascx I have the following:
protected void lnkCreateEvent_Click(object sender, EventArgs e)
{
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(
PortalSettings.ActiveTab.TabID,
"createevent"
));
}
which takes me to a URL:
http://localhost/GJ/Gigs/tabid/58/ctl/createevent/Default.aspx
and I don't see the ascx file I expected.
If you look at the code below, I haven't got very far as
string controlType = Request.QueryString.Get("ControlType");
is empty. I think I have managed to get very confused. Anybody with any best practice advise?
--------------------
My Event.ascx contains the following:
<code>
protected void Page_Init(object sender, System.EventArgs e)
{
string controlType = Request.QueryString.Get("ControlType");
m_controlToLoad = GetControlToLoad(controlType);
if (m_controlToLoad != null)
{
LoadControlType(m_controlToLoad);
}
}
private void LoadControlType(string controlToLoad)
{
PortalModuleBase portalModuleBase = (PortalModuleBase)this.LoadControl(controlToLoad);
if(portalModuleBase != null)
{
portalModuleBase.ModuleConfiguration = this.ModuleConfiguration;
portalModuleBase.ID = System.IO.Path.GetFileNameWithoutExtension(controlToLoad);
plhControls.Controls.Add(portalModuleBase);
}
}
private static string GetControlToLoad(string controlType)
{
string controlToLoad;
if (string.IsNullOrEmpty(controlType))
{
controlToLoad = "Event.ascx";
}
else{
switch (controlType.ToLower())
{
case "createevent":
controlToLoad = "EditEvent.ascx";
break;
case "editevent":
controlToLoad = "EditEvent.ascx";
break;
case "viewevent":
controlToLoad = "ViewEvent.ascx";
break;
default:
controlToLoad = "Event.ascx";
break;
}
}
return controlToLoad;
}
</code>