ASP.Net Having common menu without using master pages

ASP.Net Having common menu without using master pages : I want to have common html code snippest which can be shared by all pages without using the master page concept.
Many of u have asked

is there an equivalent to PHP include files in

This method is similar to include tag of php which fetch common html tag stored in a text file to any web page.

My common html code portion will be put on a class file in App_Code folder which is accessible to all. Changing here will reflect everywhere...

1. Now put a label on ur all aspx page where u wanna have common html code like:

               <!-- menu -->

    <asp:Label ID="lblMenu" runat="server" Text="Label"></asp:Label>

<div id="copyright">Copyright © 2011 <a href="">NTPC Limited</a></div> 

<!-- end #menu -->

2. Change the Labels Text programmatic-ally in page load event of every page

Imports common  'Where makemenu public function is defined

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

  If Not Page.IsPostBack Then
            lblMenu.Text = makemenu()
End If
End Sub

3. My common class contain a public function like this to create menu:

Public Class common

 Public Shared Function makemenu() As String
        Dim temp = "<div id=menu> <ul class=menu> " & _
         "<li class=last><a href=Default.aspx><span>Home</span></a></li> " & _
         "<li><a href=# class=parent><span>Data Updation</span></a>" & _

  "</ul></div>" & _
                 "</li>" & _
         "<li class=last><a href=login.aspx?logout=1><span>Logout</span></a></li>" & _
     "</ul> </div>"

        Return temp
    End Function
End Class

- Vinod Kotiya


Most Viewed Post

solution for facebook waiting

Connect Sony XPLOD MEX-BT2500 Bluetooth CD Receiver with ur mobile

Crystal Report : Show data horizontally (Left to right) i.e. columns as rows

Google+ Followers