?
Solved

vb.net .aspx - Display different links on different months

Posted on 2009-04-14
8
Medium Priority
?
273 Views
Last Modified: 2013-11-26
I have 12 sets of 4 page links I want to be displayed on a vb.net aspx page at different months of the year, so for example the page will display link1, link2, link3, link4 from 1st of january to the 31st of january and then link5, link6, link7, link8 from 1st of february to the 28th of february, etc, etc I would also like a text file to hold the links so that they can be easily changed at any time.

Thanks for the help!
0
Comment
Question by:Zoooink
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 25

Expert Comment

by:Luis Pérez
ID: 24136649
I don't understand for what do you want the text file. Explain it, please.
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24136807
The easiest way would be to use an XML file (its still text afterall), so it would be easier to load.
0
 
LVL 3

Author Comment

by:Zoooink
ID: 24136901
XML would be fine, though the idea of the text file is so any administrative person without web development skills could change the links, without having to go in to code or anything like that, that's the reason, with an XML version, I would need an administretive page which allows a unskilled administrator to effectivley log in and change the links on the fly.
0
Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

 
LVL 5

Expert Comment

by:prashantagarw10
ID: 24137375
In this case  my suggestion would be to use a text file with 12 rows in it(1 for each month) and have 4 comma delimited values in it. Optionally, Each value can be a pair of Link text and Link URL both of which are further separated by a delimiter. The admin people will find this easier to maintain directly and you can easily write a program that reads the file as per this logic. However it must cater for invalid conditions e.g. if someone forgets to put a delimiter.
You should be very careful as this may hinder the user experience which is not good and it may take as long as 12 months to find a incorrect data in file.

Cheers!!
0
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24137409
Ok... here is what i would do.

Create a ASPX file with a calendar object in it like this:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="CalendarXML._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
    </div>
    </form>
</body>
</html>

Then, you add the code bellow in the codebehind.  And don't forget to create your xml file.  I've included an exemple with links for the first 2 months in it.

I think we underestimate users too much.  Even a monkey can understand the pattern of the XML file
Imports System.Xml
Partial Public Class _Default
    Inherits System.Web.UI.Page
 
    Private aPathNav As System.Xml.XPath.XPathNavigator
    Private aPathDoc As System.Xml.XPath.XPathDocument
    Private aPathNodeIt As XPath.XPathNodeIterator
    Private aPathNode As XPath.XPathNavigator
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        aPathDoc = New XPath.XPathDocument("LinksFile.xml")
        aPathNav = aPathDoc.CreateNavigator()
 
        If Not IsPostBack Then
            ShowLinks(Now().Month)
        End If
    End Sub
 
    Private Sub Calendar1_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) Handles Calendar1.VisibleMonthChanged
        ShowLinks(e.NewDate.Month)
    End Sub
 
    Private Sub ShowLinks(ByVal nMonth As Integer)
        Try
            aPathNodeIt = aPathNav.Select("months/month_" & nMonth.ToString("00") & "/link")
 
            Page.Response.Write("Link lists: <BR>")
            For Each aPathNode In aPathNodeIt
                Page.Response.Write("<LI><A HREF=""" & aPathNode.Value() & """>" & aPathNode.Value() & "</A><BR>")
            Next
        Catch ex As Exception
            Page.Response.Write("No link define")
        End Try
    End Sub
End Class
 
-----------------------------------
XML File sample
<?xml version="1.0" encoding="utf-8" ?>
<months>
  <month_01>
    <link>http://www.microsoft.com</link>
    <link>http://support.microsoft.com</link>
    <link>http://msdn.microsoft.com</link>
    <link>http://technet.microsoft.com</link>
  </month_01>
 
  <month_02>
    <link>http://www.experts-exchange.com</link>
    <link>http://www.adobe.com</link>
    <link>http://www.download.com</link>
    <link>http://www.google.com</link>
  </month_02>
</months>

Open in new window

0
 
LVL 3

Author Comment

by:Zoooink
ID: 24137547
Thanks forall the replies guys,

cdebel, you seem to be on the right track of what I am after, however, Iw as thinking of using something like an if statement perhaps...

if today.now() is greater than or equal to  01/01/09 and less than or equal to 01/31/09 then
link1
link2
link3
link4
elseif...

rathar than using the calander tool, basically I want the code in the page to handle all changes in the background, so whenever the end user browses to the page each month, they get a different set of links... What do you think?
0
 
LVL 10

Accepted Solution

by:
Christian de Bellefeuille earned 2000 total points
ID: 24137596
Well, all what you have to change is to remove the calendar and use:
ShowLinks(Now().Month)

You don't need to check if its between day 1 and day 31, because you will fall into the leapyear trap, and if you compare it with dates litterally, what will happen in january 2010?  You will have to change your program code again!

So please, use Now().Month...
And remove the Calendar1 from the aspx and it will do the job
Imports System.Xml
 
Partial Public Class _Default
    Inherits System.Web.UI.Page
 
    Private aPathNav As System.Xml.XPath.XPathNavigator
    Private aPathDoc As System.Xml.XPath.XPathDocument
    Private aPathNodeIt As XPath.XPathNodeIterator
    Private aPathNode As XPath.XPathNavigator
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        aPathDoc = New XPath.XPathDocument("LinksFile.xml")
        aPathNav = aPathDoc.CreateNavigator()
 
        ShowLinks(Now().Month)
    End Sub
 
    Private Sub ShowLinks(ByVal nMonth As Integer)
        Try
            aPathNodeIt = aPathNav.Select("months/month_" & nMonth.ToString("00") & "/link")
 
            Page.Response.Write("Link lists: <BR>")
            For Each aPathNode In aPathNodeIt
                Page.Response.Write("<LI><A HREF=""" & aPathNode.Value() & """>" & aPathNode.Value() & "</A><BR>")
            Next
        Catch ex As Exception
            Page.Response.Write("No link define")
        End Try
    End Sub
End Class

Open in new window

0
 
LVL 3

Author Comment

by:Zoooink
ID: 24137734
Top notch cdebel!

I thought you might catch me on the literal thing! I did think about that after I'd submitted my post! lol

Thanks for the help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

762 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