Solved

Creating a hyperlink in DotNetNuke to a particular page by tab id when the module id is known

Posted on 2009-07-01
7
1,219 Views
Last Modified: 2012-05-07
I have a custom module in a DotNetNuke site.  You can see the module in action here: http://www.govoter.org/StateContacts/ProtectionandAdvocacyGroups/tabid/79/Default.aspx

Everything works great, except the link "All State Contact Information".  For each state in the list, this should be a link to the page where each state contact information for the given state is presented; for example, for Washington, that page would be: http://www.govoter.org/StateContacts/WashingtonStateData/tabid/110/default.aspx.  This is possible because each state in this list is generated based on data in another table using a datalist & itemtemplate.

We can take the 'WashingtonStateData' out of the target URL for simplicity and just use http://www.govoter.org/StateContacts/tabid/110/default.aspx.  The 'StateContacts' part of the URL is always the same, that's the section name I believe.  What differs is the tabid, so this is what I must determine via programming as each state contact info for the full list is rendered.

In the page listing all of the states, the data is pulled by calling up in the information maintained and stored by the StateContacts modules.  Therefore, we know the Module ID of each state's data when we load the full list.  What I need is to determine how to get the tab id of this module (each module id here will only be on one page/tab, it's unique just like the item id because states are unique).  I'm sure it can be done in code, and if that's the only way, I will live with it though I don't know off the top of my head how to do that in DotNetNuke-specific code.  I'd prefer to just use the NavigateURL function in the presentation file.  See the code below for the current presentation code that displays the entire list of contact info on a page.

Does anyone have some ideas on how I can make this link be dynamic so that it takes the user to the state-specific page?  I can share the codebehind if necessary for the backend solution if that's the only way to accomplish this, but I am not sure how I can interact with the DotNetNuke system in the backend to pull meta database information (tabid, etc) for other pages given that I only know the module id.  Thanks in advance for any help or suggestions.
ViewFullStateContact.aspx

<%@ Control language="vb" Inherits="YourCompany.Modules.FullStateContact.ViewFullStateContact" CodeFile="ViewFullStateContact.ascx.vb" AutoEventWireup="false" Explicit="True" %>

<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>

<asp:datalist id="lstStateContacts" datakeyfield="ItemID" runat="server" cellpadding="4">

  <itemtemplate>

    <table cellpadding="4" width="100%">

      <tr>

        <td valign="top" width="100%" align="left">

          <asp:Label ID="lblStateAbbreviation" runat="server" CssClass="Normal" Font-Bold="True" /> <asp:HyperLink ID="HyperLink2" NavigateUrl='' runat="server">All State Contact Information</asp:HyperLink>

          <asp:Label ID="lblStateContact" runat="server" CssClass="Normal"/>

          <hr />

        </td>

      </tr>

    </table>

  </itemtemplate>

</asp:datalist>

Open in new window

0
Comment
Question by:dageyra
  • 3
  • 3
7 Comments
 
LVL 5

Expert Comment

by:prashantagarw10
ID: 24762010
When you load this data you must be having ids of these states. At that time set the URL for this link to default.aspx with a query string value as ?tabid=[Stateid]. This will do the needful.

Cheers!
0
 
LVL 1

Author Comment

by:dageyra
ID: 24763699
Hello:

Thanks for your comment.  The state data is in a table specific to the module, so I have a module and item ID, but not the tab id.  I believe there is another table that associates the module with the tab id, and that is where I am getting caught up.  In other words, how to go from having the module id to getting the tab id, preferably in the presentation code using the function NavigateURL, but as a last case I'm sure there's a way to do it in the code-behind file.  However, for the latter, I'm not entirely sure how to query the appropriate tables using DotNetNuke-specific functions to get the tab id when only the module id is known.
0
 
LVL 5

Expert Comment

by:prashantagarw10
ID: 24764617
This is not the right thing to do. A module can be posted on multiple pages and thus its not a good practice to do this even if you know that this module will be deployed on only 1 tab.
Rather what i will suggest is that store the page titles in your web.config file and use these titles to query against the DNN database. There is a table called tabs(i recall this name but may be a bit different and customised) where in you will find all pages you have deployed. Since the tab id changes for each deployment but title is something given by user and shall remain same across the deployments so its a safer way to use page titles instead of module id or hard coding the tab id. Use a key value pair in web.config to store the titles as value and a unique name as key for the page then using this title query on tabs table and get the tab id.

I beleive this is what you were looking for.
Let me know.

Cheers!
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:dageyra
ID: 24775127
That's a very interesting suggestion. Are you suggesting that I store the name value pair such as: [PageTitle]=>[TabID] ?  This could work assuming I can determine the value for PageTitle dynamically, but since the title is related to state name & I will have the state abbreviation, this is possible. Actually, I could just use [StateAbbreviation]=>[TabID]. If I misunderstand please correct me

However, assuming I can get the tab id this way, it still is not clear to me how I can implement the NavigateURL function, because I'm not sure I can access the web.config in the .NET presentation code. Does this make sense?
0
 
LVL 5

Accepted Solution

by:
prashantagarw10 earned 500 total points
ID: 24801243
Sorry for the late reply!!!! Was away for some time.

Yes you could do it this way([StateAbbreviation]=>[TabID]) but then again redeployment or migration to different server or using a web farm will lead to changes in web.config every time. This will make the task tedious. What i was suggesting is you store a key value pair where key is some value(may be the abbr. but this will be sort of hard coded in your code behind so it should not change later) and value will be title of page to display. With this title of page you could easily find out the tabid from tabs table in DNN database and use the NavigateURL function. This will make it transparent to deployment as across the implementations of servers the page title remains same and then tab id can be queried. This will be more portable or scalable.

and yes .NET user controls can very easily access the web.config just like normal aspx pages do. Its not special case.
HTH

Cheers!
Prashant
0
 
LVL 1

Author Closing Comment

by:dageyra
ID: 31599021
good solution idea, was lacking on some of the specifics, have not been able to implement it yet but will close this question and reopen if i encounter further problems
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Read about why website design really matters in today's demanding market.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
This video teaches users how to migrate an existing Wordpress website to a new domain.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now