熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

Asp.net導航控件真的值得用嗎?

2022-06-13   來源: .NET編程 
    開始接觸menu控件感覺怎麼這麼別扭啊
  
  首先說數據訪問部分為了所謂的provider pattern一層一層的包裝而且都是些黑盒子雖然概念是挺先進結構好象也很清楚但還是讓我覺的迷迷糊糊至於嘛只是想做幾個數據驅動的menu而已還有那個前台的menu類那麼多的Properties尤其想到menu類也是個黑盒子一點都不知道它生成的xhtml會是什麼樣的而我只有一點點css知識而已想到這裡連嘗試的欲望都沒了還不如自己動手親自寫一個menu呢網上好象有好多現成的javascript類比如這個
  
  
  
  Div_css 結構的雖然沒有 控件那麼漂亮可也很是實用至少都是透明的不過後台有點麻煩當時的想法是
  
   設計一個類sitemap從數據庫裡讀導航信息然後存到一個dataset中
  
   在application_start 事件處理函數中 實例化一個sitemap 和一個sqlCachedependency 插入到cache中
  
   一個dependency的回調函數以更新cache中的數據
  
   從cache中提取數據生成menu
  
  這樣一來可以想象defaultmaster的代碼的代碼會亂七八糟非但不太容易寫寫好的代碼也不太容易復用而且還有關於cache的很多問題
  
  肯定有其他辦法好多東西我都沒有接觸過不過現在想想 provider pattern還是不錯一層api連接表示層一層api連接數據訪問層
  
  
  
  被迫學習menu類希望它不要太讓人意外終於明白為什麼開源讓那麼多人激動開放透明啊!
  
  
  
  
  /**//*****************************************************
  * ypSlideOutMenu
  * //
  *
  * a nice little script to create exclusive slideout
  * menus for ns ns mozilla opera ie ie on
  * mac and win Ive got no linux or unix to test on but
  * it should(?) work
  *
  * Revised:
  * // : added hideAll()
  * // : added writeCSS() to support more
  *
  
  
  
   than menus
  *
  * youngpup
  *****************************************************/
  ypSlideOutMenuRegistry = []
  ypSlideOutMenuaniLen =
  ypSlideOutMenuhideDelay =
  ypSlideOutMenuminCPUResolution =
  // constructor
  function ypSlideOutMenu(id dir left top width height)
  {
  thisie = documentall ? :
  thisns = documentlayers ? :
  thisdom = documentgetElementById ? :
  if (thisie || thisns || thisdom) {
  thisid = id
  thisdir = dir
  thisorientation = dir == left || dir == right ? h : v
  thisdirType = dir == right || dir == down ? : +
  thisdim = thisorientation == h ? width : height
  thishideTimer = false
  thisaniTimer = false
  thisopen = false
  thisover = false
  thisstartTime =
  thisgRef = ypSlideOutMenu_+id
  eval(thisgRef+=this)
  ypSlideOutMenuRegistry[id] = this
  var d = document
  var strCSS = ;
  strCSS += # + thisid + Container { visibility:hidden;
  strCSS += left: + left + px;
  strCSS += top: + top + px;
  strCSS += overflow:hidden; zindex:; }
  strCSS += # + thisid + Container # + thisid + Content { position:absolute;
  strCSS += width: + width + px;
  strCSS += height: + height + px;
  strCSS += clip:rect( + width + + height + );
  strCSS += }
  thiscss = strCSS;
  thisload()
  }
  }
  ypSlideOutMenuwriteCSS = function() {
  documentwriteln(<style type=text/css>);
  for (var id in ypSlideOutMenuRegistry) {
  documentwriteln(ypSlideOutMenuRegistry[id]css);
  }
  documentwriteln(</style>);
  }
  ypSlideOutMenuprototypeload = function() {
  var d = document
  var lyrId = thisid + Container
  var lyrId = thisid + Content
  var obj = thisdom ? dgetElementById(lyrId) : thisie ? dall[lyrId] : dlayers[lyrId]
  if (obj) var obj = thisns ? objlayers[lyrId] : thisie ? dall[lyrId] : dgetElementById(lyrId)
  var temp
  if (!obj || !obj) windowsetTimeout(thisgRef + load() )
  else {
  ntainer = obj
  nu = obj
  thisstyle = thisns ? nu : nustyle
  thishomePos = eval( + thisdirType + thisdim)
  thisoutPos =
  thisaccelConst = (thisoutPos thishomePos) / ypSlideOutMenuaniLen / ypSlideOutMenuaniLen
  // set event handlers
  if (thisns) nucaptureEvents(EventMOUSEOVER | EventMOUSEOUT);
  nuonmouseover = new Function(ypSlideOutMenushowMenu( + thisid + ))
  nuonmouseout = new Function(ypSlideOutMenuhideMenu( + thisid + ))
  //set initial state
  thisendSlide()
  }
  }
  ypSlideOutMenushowMenu = function(id)
  {
  var reg = ypSlideOutMenuRegistry
  var obj = ypSlideOutMenuRegistry[id]
  if (ntainer) {
  objover = true
  for (menu in reg) if (id != menu) ypSlideOutMenuhide(menu)
  if (objhideTimer) { reg[id]hideTimer = windowclearTimeout(reg[id]hideTimer) }
  if (!objopen && !objaniTimer) reg[id]startSlide(true)
  }
  }
  ypSlideOutMenuhideMenu = function(id)
  {
  var obj = ypSlideOutMenuRegistry[id]
  if (ntainer) {
  if (objhideTimer) windowclearTimeout(objhideTimer)
  objhideTimer = windowsetTimeout(ypSlideOutMenuhide( + id + ) ypSlideOutMenuhideDelay);
  }
  }
  ypSlideOutMenuhideAll = function()
  {
  var reg = ypSlideOutMenuRegistry
  for (menu in reg) {
  ypSlideOutMenuhide(menu);
  if (menuhideTimer) windowclearTimeout(menuhideTimer);
  }
  }
  ypSlideOutMenuhide = function(id)
  {
  var obj = ypSlideOutMenuRegistry[id]
  objover = false
  if (objhideTimer) windowclearTimeout(objhideTimer)
  objhideTimer =
  if (objopen && !objaniTimer) objstartSlide(false)
  }
  ypSlideOutMenuprototypestartSlide = function(open) {
  this[open ? onactivate : ondeactivate]()
  thisopen = open
  if (open) thissetVisibility(true)
  thisstartTime = (new Date())getTime()
  thisaniTimer = windowsetInterval(thisgRef + slide() ypSlideOutMenuminCPUResolution)
  }
  ypSlideOutMenuprototypeslide = function() {
  var elapsed = (new Date())getTime() thisstartTime
  if (elapsed > ypSlideOutMenuaniLen) thisendSlide()
  else {
  var d = Mathround(Mathpow(ypSlideOutMenuaniLenelapsed ) * thisaccelConst)
  if (thisopen && thisdirType == ) d = d
  else if (thisopen && thisdirType == +) d = d
  else if (!thisopen && thisdirType == ) d = thisdim + d
  else d = thisdim + d
  thismoveTo(d)
  }
  }
  ypSlideOutMenuprototypeendSlide = function() {
  thisaniTimer = windowclearTimeout(thisaniTimer)
  thismoveTo(thisopen ? thisoutPos : thishomePos)
  if (!thisopen) thissetVisibility(false)
  if ((thisopen && !thisover) || (!thisopen && thisover)) {
  thisstartSlide(thisover)
  }
  }
  ypSlideOutMenuprototypesetVisibility = function(bShow) {
  var s = thisns ? ntainer : ntainerstyle
  svisibility = bShow ? visible : hidden
  }
  ypSlideOutMenuprototypemoveTo = function(p) {
  thisstyle[thisorientation == h ? left : top] = thisns ? p : p + px
  }
  ypSlideOutMenuprototypegetPos = function(c) {
  return parseInt(thisstyle[c])
  }
  ypSlideOutMenuprototypeonactivate = function() { }
  ypSlideOutMenuprototypeondeactivate = function() { }
From:http://tw.wingwit.com/Article/program/net/201311/12693.html
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.