Part 155 Binding asp net menu control to an xml file using xmldatasource control

  • دعنا نشارك هذا :
ترتيب الدرس : 155
المدة : 00:10:20
التحكم :
Text version of the video
http://csharp-video-tutorials.blogspot.com/2013/10/part-155-binding-aspnet-menu-control-to.html

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation1

Slides
http://csharp-video-tutorials.blogspot.com/2014/10/binding-aspnet-menu-control-to-xml-file.html

All ASP .NET Text Articles
http://csharp-video-tutorials.blogspot.com/p/free-aspnet-video-tutorial.html

All ASP .NET Slides
http://csharp-video-tutorials.blogspot.com/p/aspnet-slides.html

ASP.NET Playlist
https://www.youtube.com/playlist?listPL4cyC4G0M1RQcB4IYS_zwkyBwMyx5AnDM

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view1&sortdd

All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists

In this video, we will discuss binding asp.net menu control to an xml file using xmldatasource control. This is continuation to Part 154, please watch Part 154 before proceeding.

1. Add an XML file and name it MenuData.xml. Include the menu item xml.

2. Drag and drop an XmlDataSource control on the webform. Set XPath and DataFile attributes. Notice that DataFile attribute points to the XML file that we added in Step 1.

3. Drag and drop a menu control and set DataSourceID attribute to the xmldatasource control we created in step 2. Also, set DataBindings.

4. To set the styles for the selected menu item, copy and paste the following code in the code-behind file.
private void Check(MenuItem item)
{
if (item.NavigateUrl.Equals(Request.AppRelativeCurrentExecutionFilePath,
StringComparison.InvariantCultureIgnoreCase))
{
item.Selectedtrue;
}
else if (item.ChildItems.Count ] 0)
{
foreach (MenuItem menuItem in item.ChildItems)
{
Check(menuItem);
}
}
}

protected void Menu1_PreRender(object sender, EventArgs e)
{
foreach (MenuItem item in Menu1.Items)
{
Check(item);
}
}

سيتم تفعيل التعليقات قريبا

y
Sep 23, 2020 07:32:27
youtube