Ok, so I finally had a chance to spend a couple hours poking around the codes (after my whole family got sick for 2 weeks! geez...). I must admit I like this ASP.net developing environment. I like the syntax - For example, Me.DataList4.DataSource means "Ok. we'll dump this variale to my template file. The location is Datalist4. and yeah, that's Datasource.". Everytime I start typing something in the code,,, a sneaky drop-down menu coming up and tells me exactly what I can put (functions, variables, etc.). Everything is new to me and I like it a lot.
Anyway, my final goal for this project is to create the simple sitemap module, which displays all pages alphabetically. I got this so far.
and here are the codes. I basically stole..."cough" borrowed Michael's "SuperSimple" module. His code is calling a module table and load them all on the page. Instead, my code calls "Tabs" table.
SiteMapPlus.ascx
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="SiteMapPlus.ascx.vb" Inherits="DesktopModules_SiteMapPlus" %>
<a>A</a>
<asp:DataList ID="DataList1" runat="server" DataKeyField="TabID">
<ItemTemplate>
<asp:HyperLink ID="TabNameLabel" runat="server" Text='<%# Eval("TabName") %>' NavigateUrl='<%# formatURL(Eval("TabID")) %>'></asp:HyperLink>
<br />
</ItemTemplate>
</asp:DataList>
<br />
<a>B</a>
<asp:DataList ID="DataList2" runat="server" DataKeyField="TabID">
<ItemTemplate>
<asp:HyperLink ID="TabNameLabel" runat="server" Text='<%# Eval("TabName") %>' NavigateUrl='<%# formatURL(Eval("TabID")) %>'></asp:HyperLink>
<br />
</ItemTemplate>
</asp:DataList>
<br />
<a>C</a>
<asp:DataList ID="DataList3" runat="server" DataKeyField="TabID">
<ItemTemplate>
<asp:HyperLink ID="TabNameLabel" runat="server" Text='<%# Eval("TabName") %>' NavigateUrl='<%# formatURL(Eval("TabID")) %>'></asp:HyperLink>
<br />
</ItemTemplate>
</asp:DataList>
<br />
<a>D</a>
<asp:DataList ID="DataList4" runat="server" DataKeyField="TabID">
<ItemTemplate>
<asp:HyperLink ID="TabNameLabel" runat="server" Text='<%# Eval("TabName") %>' NavigateUrl='<%# formatURL(Eval("TabID")) %>'></asp:HyperLink>
<br />
</ItemTemplate>
</asp:DataList>
<br />
<a>E</a>
<asp:DataList ID="DataList5" runat="server" DataKeyField="TabID">
<ItemTemplate>
<asp:HyperLink ID="TabNameLabel" runat="server" Text='<%# Eval("TabName") %>' NavigateUrl='<%# formatURL(Eval("TabID")) %>'></asp:HyperLink>
<br />
</ItemTemplate>
</asp:DataList>
SiteMapPlus.ascx.vb
Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Security.PortalSecurity
Partial Class DesktopModules_SiteMapPlus
Inherits Entities.Modules.PortalModuleBase
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
ShowDataPlus()
End If
End Sub
Private Sub ShowDataPlus()
Dim mySqlString As New StringBuilder()
Dim SearchString As String = "a"
mySqlString.Append("SELECT TabID,TabName ")
mySqlString.Append("FROM {databaseOwner}{objectQualifier}Tabs ")
mySqlString.Append("WHERE PortalID = '")
mySqlString.Append(PortalSettings.ActiveTab.PortalID)
mySqlString.Append("' AND ")
mySqlString.Append("TabName like @SearchString + '%' ")
mySqlString.Append("ORDER BY TabName ASC")
Dim myParam As SqlParameter = New SqlParameter("@SearchString", SqlDbType.VarChar, 150)
myParam.Value = SearchString
Me.DataList1.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)
Me.DataList1.DataBind()
SearchString = "b"
myParam.Value = SearchString
Me.DataList2.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)
Me.DataList2.DataBind()
SearchString = "c"
myParam.Value = SearchString
Me.DataList3.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)
Me.DataList3.DataBind()
SearchString = "d"
myParam.Value = SearchString
Me.DataList4.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)
Me.DataList4.DataBind()
SearchString = "e"
myParam.Value = SearchString
Me.DataList5.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)
Me.DataList5.DataBind()
End Sub
Public Function formatURL(ByVal strTabID As String) As String
Return NavigateURL(Int32.Parse(strTabID))
End Function
End Class
This works. I just have to add F-Z and done! However, I don't like how it looks in the code. My dream would be loading all tabs to multidimensional array and dump it into the template file.
UltimateTabArray[A]{"Action List", "A Page", "Ant page"}
UltimateTabArray[B]{"Boston Redsox","Bite me", "Bow"}
UltimateTabArray[C]{"Costume", "Cost", "Come to Vermont","contact Us"}
.... to be continue until Z and the rest (numbers, etc)
Then dump this array to the SiteMapPlus.ascx. I need to find out how I can dynamically generate <asp:DataList> tag Datalist1 through 27 or 28 so the template file is more simplier than my version above.
QUESTIONS:
1. How do I hide admin, host, and other unwanted tab hid from public? Does this have to access to tab permission table?
2. Can template file contain "If" statement? So I can display "Oops... no page under character Z" instead of a blank space.
3. Any other hint, tips,,,,
Forgive me my rough coding... I have no ASP.Net coding background at all.
>> Johnny
Yes, I liked his tutorials. Thoes tutorials are the first one I looked at it.
>>Carlos
Thank you for the suggestion, Carlos. However, I can't learn from books. I usually just tackle on the existing code and modify it & hack it.... and eventually I can understand the whole structure and its syntax. That's the only way I can learn stuff. hehe
This thread is MOVED to following location: http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/253233/scope/posts/Default.aspx