您的位置:首页 > 编程语言 > ASP

深入了解aspx页面的智能导航(SmartNavigation)功能(downmoon原创)

2005-07-05 11:11 465 查看
在启用页面的智能导航功能Page.SmartNavigation=true后,可以有提交页面后自动回到刷新前的页面位置!这是微软的.net提供的的一个很人性化的功能!(不是广告^_^)

可以查看一下此时页面的源文件,《body************的下方应该有这么一行:





<
IFRAME
ID
=__hifSmartNav
NAME
=__hifSmartNav
STYLE
=display:none
src
="/aspnet_client/system_web/1_1_4322/SmartNav.htm"
></
IFRAME
>





这其实是.net 自动添加的一个Frame 所以实际是这个页面此时已经变成一个多Frame页面了!

从而会带来一个页面刷新问题:

在该页面的按钮保存事件中



string
str
=
"
frmaddMessage.aspx?strStatus=Edit&lngSysID=
"
+
this
.lngSysID.ToString()
+
"
&id=
"
+
lngID.ToString()
+
"
&Manage=1
"
;




string
script
=

string
.Format(
@"
<script language=javascript> alert('保存成功!请 上传附件 或 返回!'); window.location.href='{0}';</script>
"
,str);



Response.Write(script);





执行上碳代码时会提示(这是个脚本错误):

“contentwindow.documentMent不是对象错误” 

其实这是由于Frame页面没有同步刷新引起的!

只须在代码前加上

Page.SmartNavigation=false,从而把页面临时改为单 Frame页面即可!

附微软提供的一个同时刷新多个Frame的例子!~



<
HTML
xmlns:MSHelp
=http://msdn.microsoft.com/msHelp
>



<
head
>





<
SCRIPT
>
...



function
fnNavigate()





...
{




for
(i
=
0
;i
<
document.all.length;i
++
)






...
{




if
(document.all(i).tagName
==
"
IFRAME
"
)






...
{



document.all(i).contentWindow.location
=

" http://www.msn.com "
;



}



}



}



</
SCRIPT
>




<
TITLE
>
contentWindow
</
TITLE
>



<
LINK
REL
="stylesheet"
HREF
="/workshop/samples/samples.css"
_fcksavedurl
=""
/workshop/samples/samples.css"" _fcksavedurl
=""
/workshop/samples/samples.css"" _fcksavedurl
=""
/workshop/samples/samples.css"" TYPE
="text/css"
>





<
LINK
REL
="stylesheet"
TYPE
="text/css"
HREF
="ms-help://Hx/HxRuntime/HxLink.css"
><
STYLE
TYPE
="text/css"
>
...





PRE.clsCode
{...}
{
font-size
:
110%
;

}





PRE.clsSyntax
{...}
{
font-size
:
100%
;

}







TD DIV.clsBeta
{...}
{
display
:
none
;
}





MSHelp:link
{...}
{



color
:
#0000ff
;



text-decoration
:
underline
;



cursor
:
hand
;



hoverColor
:
#3366ff
;



filterString
:

;
}



</
STYLE
>



</
HEAD
>





<
BODY
>



<
H2
>
Using the contentWindow Property
</
H2
>



Click the button below to make the
<
b
>
IFRAMEs
</
b
>
navigate to a new URL.



<
P
>



<
BUTTON
onclick
="fnNavigate();"
>
Navigate Frames
</
BUTTON
>



<
P
/>



<
IFRAME
SRC
="http://www.microsoft.com"
STYLE
="width:100%;height:150px;"
>



</
IFRAME
>



<
P
/>



<
IFRAME
SRC
="http://www.microsoft.com"
STYLE
="width:100%;height:150px;"
>



</
IFRAME
>



<
P
/>



<
IFRAME
SRC
="http://www.microsoft.com"
STYLE
="width:100%;height:150px;"
/>



</
IFRAME
>





</
body
>



</
html
>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: