![]() |
Web Development »
ASP.NET »
Howto
Intermediate
License: The Code Project Open License (CPOL)
HOW TO REDIRECT TO SPECIFIC CONTROL OF SPECIFIC TAB IN DOTNETNUKEBy Prashant LakhlaniHOW TO REDIRECT TO SPECIFIC CONTROL OF SPECIFIC TAB IN DOTNETNUKE |
C#, Javascript, CSS, HTML.NET2.0, ASP, ASP.NET, Ajax, Dev
|
||||||||||
|
|
|
||||||||||||||||
Hi friends. DotNetNuke is a well known open source CMS. When I go through the forums of the website, there exists a common question many times by different developers that how to redirect to a specific control at the specific tab in DotNetNuke. I will try to help the new developers getting answer of this question.
As
every newbie starting the DotNetNuke development has always a question like
this in their lives. The basic idea behind doing this is:
I’m
trying to make sure how easily we can do this using an example.
Create a default
control
Create a control called _default in your root directory which looks like this:
_DEFAULT.ASCX
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="_Default.ascx.cs" Inherits="PMJ.Modules.Contact._Default" %>
<table id="Table1" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
<tr>
<td valign="top" align="center">
<p align="center">
<asp:PlaceHolder ID="phMain" runat="server"></asp:PlaceHolder>
</p>
</td>
</tr>
<tr>
<td valign="top" align="center">
<asp:Label ID="lblModuleSettings" runat="server" resourcekey="lblModuleSettings"
ForeColor="Red" Visible="False">Please update module settings...contact Portal Admin.</asp:Label></td>
</tr>
</table>
_DEFAULT.ASCX.CS
partial class _Default : PortalModuleBase
{
private string m_ModuelControl = "Contacts.ascx";//1. Default Module Control to load
protected void Page_Load(object sender, EventArgs e)
{
LoadModuleControl(); // Call LoadModuleControl Method to load a specific control
}
private void LoadModuleControl()
{
if (Request.QueryString["mctl"] != null)//3. Read control name from querystring
{
m_ModuelControl = Request.QueryString["mctl"].ToString() + ".ascx";
}
//4. check authorization here if you want, otherwise comment out or skip this step
switch (m_ModuelControl)
{
case "AddContact.ascx":
//5. check if user is authorized otherwise redirect to access denied page
// Response.Redirect(Globals.NavigateURL("Access Denied"), true);
break;
case "ContactNotes.ascx":
break;
}
//6. Load a specific control
PortalModuleBase objPortalModuleBase = (PortalModuleBase)LoadControl(m_ModuelControl);
objPortalModuleBase.ModuleConfiguration = ModuleConfiguration;
objPortalModuleBase.ID = System.IO.Path.GetFileNameWithoutExtension(m_ModuelControl);
phMain.Controls.Add(objPortalModuleBase);
}
}
So let’s step by step go through the details of the code.
So the last thing to do is, When you redirect from any tab, just do this:
TabController objtab = new TabController();
TabInfo objtabinfo = new TabInfo();
objtabinfo = objtab.GetTabByName("Contacts", PortalId);
Response.Redirect(Globals.NavigateURL(objtabinfo.TabID, "", "mctl=" + "ContactNote")));
Remember that for this code to work: • You need a tab called “Contacts“ in your portal • You need a control called ContactNote.ascx in your module • You need to include the namespace DotNetNuke.Entities.Tabs at the top of your page where you write the redirect code above. Wish you a Happy coding with DotNetNuke.
1 message have been posted for this article.
Visit http://www.codeproject.com/KB/aspnet/DOTNETNUKE_NAVIGATION.aspx to post and view comments
on this article, or click
here to get a
print view with messages.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 24 Feb 2008 Editor: |
Copyright 2008 by Prashant Lakhlani Everything else Copyright © CodeProject, 1999-2010 Web20 | Advertise on the Code Project |