Mini Kabibi Habibi
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using DevExpress.Web.ASPxDataView;
using DevExpress.Web.ASPxClasses;
using System.Threading;
public partial class _Default : System.Web.UI.Page {
const string
TagNameRouteValueKey = "tagName",
WatchVideoTitleRouteValueKey = "watchVideoTitle",
StatisticsVideoTitleRouteValueKey = "statisticsVideoTitle",
NavigationViewControlPath = "~/Controls/NavigationView.ascx",
VideoViewControlPath = "~/Controls/VideoView.ascx",
StatisticsViewControlPath = "~/Controls/StatisticsView.ascx";
protected string TagName {
get { return GetRouteDataValue(TagNameRouteValueKey); }
}
protected string WatchVideoTitle {
get { return GetRouteDataValue(WatchVideoTitleRouteValueKey); }
}
protected string StatisticsVideoTitle {
get { return GetRouteDataValue(StatisticsVideoTitleRouteValueKey); }
}
protected string GetRouteDataValue(string key) {
return RouteData.Values[key] != null ? Server.UrlDecode(RouteData.Values[key].ToString()) : string.Empty;
}
protected void ShowVideoTabs(string videoTitle) {
var encodedTitle = Server.UrlEncode(videoTitle);
tcVideo.Tabs.FindByName("Video").NavigateUrl = "~/Watch/" + encodedTitle;
tcVideo.Tabs.FindByName("Statistics").NavigateUrl = "~/Statistics/" + encodedTitle;
tcVideo.Visible = true;
}
protected void InitializeNavigationView() {
var navigationView = LoadControl(NavigationViewControlPath) as NavigationView;
navigationView.TagName = TagName;
viewPlaceholder.Controls.Add(navigationView);
tcVideo.Visible = false;
}
protected void InitializeVideoView() {
var videoViewControl = LoadControl(VideoViewControlPath) as VideoView;
videoViewControl.VideoTitle = WatchVideoTitle;
viewPlaceholder.Controls.Add(videoViewControl);
ShowVideoTabs(WatchVideoTitle);
tcVideo.ActiveTab = tcVideo.Tabs.FindByName("Video");
}
protected void InitializeStatisticsView() {
var statisticsView = LoadControl(StatisticsViewControlPath) as StatisticsView;
statisticsView.VideoTitle = StatisticsVideoTitle;
viewPlaceholder.Controls.Add(statisticsView);
ShowVideoTabs(StatisticsVideoTitle);
tcVideo.ActiveTab = tcVideo.Tabs.FindByName("Statistics");
}
protected override void OnInit(EventArgs e) {
if(!string.IsNullOrEmpty(WatchVideoTitle))
InitializeVideoView();
else if(!string.IsNullOrEmpty(StatisticsVideoTitle))
InitializeStatisticsView();
else
InitializeNavigationView();
base.OnInit(e);
}
}