Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Skmmenu adding menus through xml and dynamically doesnt work

Posted on 2006-11-30
9
Medium Priority
?
539 Views
Last Modified: 2012-06-27
I tried to use the skmmenu control with an xml file to create a menu then I tried to programatically /  dynamically add more menu items. But on databind, i dont see these new items. It seems like skmmenu will work with just xml or just dynamic menus not both

Is this true ?
0
Comment
Question by:opstechnology
[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
  • 3
  • 2
9 Comments
 
LVL 5

Expert Comment

by:Collindsouza
ID: 18050666
Don't you mean that you want to inset xml nodes dynamically into the Menu.xml file ??
0
 

Author Comment

by:opstechnology
ID: 18050684
no i mean i create a menu using an xml file like this
This is the XML file simplexml.xml
******************************************************************
<?xml version="1.0" encoding="utf-8" ?>
<menu>
      <menuItem>
            <text>Admin</text>
            <width>100</width>
            <subMenu>
                  <menuItem>
                        <url>fraBudgetEntrySearch.aspx</url>
                        <text>Budget Entry Search</text>
                        <target>fbody</target>
                  </menuItem>
            </subMenu>
      </menuItem>
      <menuItem id="2.0">
            <text>Reports</text>
      </menuItem>
</menu>

************************************************************************
This is my code

Protected WithEvents Menu1 As skmMenu.Menu

Menu1.DataSource = Server.MapPath("SimpleXML.xml")
Menu1.Layout = skmMenu.MenuLayout.Horizontal
Menu1.DataBind()

'Then I'd like to add more menus dynamically

                Dim men As New skmMenu.MenuItem
                Dim submen As New skmMenu.MenuItem

                submen.Text = "Nothing"

                men.Url = "http://www.yahoo.com"
                men.Text = "Yahoo!"
                men.Target = "fbody"

                Dim ind As Integer

                submen.SubItems.Add(men)
                Menu1.Items.Add(submen)

I dont see this new menu item when i run the app

But if i just dynamically add (no xml) then i see it. How can i use both ?
0
 
LVL 5

Accepted Solution

by:
Collindsouza earned 2000 total points
ID: 18050782
example:

SqlDataReader GroupMenuDataReader = SqlHelper.ExecuteReader(ConnectionString, CommandType.Text, "SELECT * FROM MENUS");
while (GroupMenuDataReader.Read())
{
GroupMenu MyGroupMenu = new GroupMenu();
MyGroupMenu.MenuId = int.Parse(GroupMenuDataReader["MENU_ID"].ToString());
MyGroupMenu.MenuName = GroupMenuDataReader["MENU_NAME"].ToString();
MyGroupMenu.MenuDefaultCssClass = GroupMenuDataReader["MENU_DEFAULTCSSCLASS"].ToString();
etc...

Flag = false;
TextWriter stringWriter = new StringWriter();
XmlTextWriter MyXmlTextWriter = new XmlTextWriter(stringWriter);
DataSet MyDataSet = OracleHelper.ExecuteDataset(ConnectionString, CommandType.Text, "SELECT * FROM MENU_ITEMS WHERE (MENU_ID = " + MyGroupMenu.MenuId + ")");

MyXmlTextWriter.WriteStartDocument();
MyXmlTextWriter.WriteStartElement("menu");

GatherMenuItems(ref MyXmlTextWriter, ref MyDataSet,0);

XmlDocument MyXmlDocument = new XmlDocument();
MyXmlDocument.LoadXml(stringWriter.ToString());
XmlFileSrc = "MenuData" + MyGroupMenu.MenuId + GroupId + ".xml";
MyXmlDocument.Save(XmlFileSrc);
MyGroupMenu.DataSource = XmlFileSrc;
MyDataSet.Clear();
}
GroupMenuDataReader.Close();



----------
private void GatherMenuItems(ref XmlTextWriter MyXmlTextWriter, ref DataSet MyDataSet, int ParentMenuItemId)
{
DataRow[] FilterDataRow;
FilterDataRow = MyDataSet.Tables[0].Select("PARENT_MENUITEM_ID = '" + ParentMenuItemId + "'","MENUITEM_ORDER");

if (Flag == true && FilterDataRow.Length > 0)
{
MyXmlTextWriter.WriteStartElement("subMenu");
}

for (int x=0; x<FilterDataRow.Length; x++)
{

if (FilterDataRow[x]["MENUITEM_TYPE"] != System.DBNull.Value)
{
if (FilterDataRow[x]["MENUITEM_TYPE"].ToString() == "MenuSeparator")
{
MyXmlTextWriter.WriteStartElement("menuSpacer");
MyXmlTextWriter.WriteStartElement("spacermarkup");
MyXmlTextWriter.WriteStartElement("hr");
MyXmlTextWriter.WriteEndElement();
MyXmlTextWriter.WriteEndElement();
MyXmlTextWriter.WriteEndElement();
continue;
}
}

Flag = true;
MyXmlTextWriter.WriteStartElement("menuItem");


if (FilterDataRow[x]["MENUITEM_TEXT"] != System.DBNull.Value)
{
MyXmlTextWriter.WriteStartElement("text");
MyXmlTextWriter.WriteString(FilterDataRow[x]["MENUITEM_TEXT"].ToString());
MyXmlTextWriter.WriteEndElement();
}

etc...
GatherMenuItems(ref MyXmlTextWriter, ref MyDataSet, int.Parse(FilterDataRow[x]["MENUITEM_ID"].ToString()));
MyXmlTextWriter.WriteEndElement();
}

if (Flag == true && FilterDataRow.Length > 0)
{
MyXmlTextWriter.WriteEndElement();
}
}
0
 

Author Comment

by:opstechnology
ID: 18055385
Can u give me an example where part of the menu is pulled from an xml file and the rest of the menu items are adding programatically?
0
 
LVL 5

Expert Comment

by:Collindsouza
ID: 18290890
why delete?? experts have provided a valid solution...
i suggest please split points between opstechnology and Collindsouza
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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

597 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