asp.net

位置:IT落伍者 >> asp.net >> 浏览文章

Asp.net导航控件真的值得用吗?


发布日期:2021年04月12日
 
Asp.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() { }               

上一篇:asp.net(C#)套用模板操作Excel

下一篇:ASP.NET底层架构之从浏览器到ASP.NET