Hi mahalaxmi
Welcome to asp.net
One way of making the change from the content page to master page is to dynamically update the menu.
Add the new item, by right-clicking your project and click on the add item, add the sitemap. Fill the sitemap, by providing the "title", "description", "url" to navigate.
then add the Menu from the navigation Tab of toolbar and choose the new sitemapdatasource.
then on the ContentPage create an event of OnSelectedIndexChanged, by double clicking the comboBox or from the property of the ComboBox/DropDown
then add the following code. DAL in the code is just a CS file which open and close the connection to DB.
-
if (!IsPostBack)
-
{
-
SqlConnection source = DAL.getConnection();
-
-
SqlCommand cmd = new SqlCommand("SELECT * FROM table_statics", source);
-
DAL.openConnection();
-
SqlDataReader reader1 = cmd.ExecuteReader();
-
-
string sFileName = Server.MapPath("web.sitemap");//@"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\admin-site\Web.sitemap");
-
-
Encoding enc = Encoding.UTF8;
-
XmlTextWriter objXMLTW = new XmlTextWriter(sFileName, enc);
-
try
-
{
-
-
objXMLTW.WriteStartDocument();//xml document open
-
-
objXMLTW.WriteStartElement("siteMap");
-
//first Node of the Menu open
-
objXMLTW.WriteStartElement("siteMapNode");
-
//Title attribute set
-
objXMLTW.WriteAttributeString("title", "Home");
-
objXMLTW.WriteAttributeString("description",
-
"This is home");//Description attribute set
-
objXMLTW.WriteAttributeString("url",
-
"http://www.home.com");//URL attribute set
-
//Loop and create nodes
-
while (reader1.Read())
-
{
-
// int MasterID = reader1.GetInt32(0);
-
objXMLTW.WriteStartElement("siteMapNode");
-
objXMLTW.WriteAttributeString("title",
-
reader1.GetString(1));
-
objXMLTW.WriteAttributeString("description",
-
reader1.GetString(2));
-
objXMLTW.WriteAttributeString("url",
-
reader1.GetString(3));
-
-
-
-
objXMLTW.WriteEndElement();//Close the siteMapNode
-
}
-
-
-
objXMLTW.WriteEndElement();//Close the first siteMapNode
-
objXMLTW.WriteEndDocument();//xml document closed
-
-
}
-
finally
-
{
-
objXMLTW.Flush();
-
objXMLTW.Close();
-
reader1.Close();
-
-
}
-
source.Close();
-
-
}
-
DAL.closeConnection();
-
By adding this function, if you change the url in DB you'll see that the changes are automatically occure in master pages