updated value from a master page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mahalaxmi
    New Member
    • Jun 2007
    • 1

    updated value from a master page

    hi,

    i would like to know
    how to get the updated value from a master page so that i can update my content page.

    Description:
    i have a menu bar in master page and a dropdown control in Content page.
    wen i select another item from the dropdown accordingly some actions must occur in the master page also...

    but my code executes only for the content page alone.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by mahalaxmi
    hi,

    i would like to know
    how to get the updated value from a master page so that i can update my content page.

    Description:
    i have a menu bar in master page and a dropdown control in Content page.
    wen i select another item from the dropdown accordingly some actions must occur in the master page also...

    but my code executes only for the content page alone.
    Hi Mahalaxmi :) Welcome to theScripts.
    Hope you like it here.

    Have you thought about putting the menu into your content page?
    What are you using for your menu?

    -Frinny

    Comment

    • kashifkashif
      New Member
      • Jun 2007
      • 3

      #3
      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", "descriptio n", "url" to navigate.
      then add the Menu from the navigation Tab of toolbar and choose the new sitemapdatasour ce.

      then on the ContentPage create an event of OnSelectedIndex Changed, 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.
      [code=cpp]
      if (!IsPostBack)
      {
      SqlConnection source = DAL.getConnecti on();

      SqlCommand cmd = new SqlCommand("SEL ECT * FROM table_statics", source);
      DAL.openConnect ion();
      SqlDataReader reader1 = cmd.ExecuteRead er();

      string sFileName = Server.MapPath( "web.sitema p");//@"C:\Documen ts and Settings\Admini strator\My Documents\Visua l Studio 2005\WebSites\a dmin-site\Web.sitema p");

      Encoding enc = Encoding.UTF8;
      XmlTextWriter objXMLTW = new XmlTextWriter(s FileName, enc);
      try
      {

      objXMLTW.WriteS tartDocument();//xml document open

      objXMLTW.WriteS tartElement("si teMap");
      //first Node of the Menu open
      objXMLTW.WriteS tartElement("si teMapNode");
      //Title attribute set
      objXMLTW.WriteA ttributeString( "title", "Home");
      objXMLTW.WriteA ttributeString( "descriptio n",
      "This is home");//Description attribute set
      objXMLTW.WriteA ttributeString( "url",
      "http://www.home.com");//URL attribute set
      //Loop and create nodes
      while (reader1.Read() )
      {
      // int MasterID = reader1.GetInt3 2(0);
      objXMLTW.WriteS tartElement("si teMapNode");
      objXMLTW.WriteA ttributeString( "title",
      reader1.GetStri ng(1));
      objXMLTW.WriteA ttributeString( "descriptio n",
      reader1.GetStri ng(2));
      objXMLTW.WriteA ttributeString( "url",
      reader1.GetStri ng(3));



      objXMLTW.WriteE ndElement();//Close the siteMapNode
      }


      objXMLTW.WriteE ndElement();//Close the first siteMapNode
      objXMLTW.WriteE ndDocument();//xml document closed

      }
      finally
      {
      objXMLTW.Flush( );
      objXMLTW.Close( );
      reader1.Close() ;

      }
      source.Close();

      }
      DAL.closeConnec tion();
      [/code]

      By adding this function, if you change the url in DB you'll see that the changes are automatically occure in master pages

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Thanks Kashifkashif for the detailed help!
        Hopefully he is using a menu control and this information can help him out :)

        -Frinny

        Comment

        Working...