提交页面的定位--scrollIntoView的用法
定位 用法 页面 -- 提交
2023-06-13 09:13:53 时间
提交页面定位问题一直骚扰我,比如我们在DataGrid外面加了来使DataGrid在一定区域内呈现,这样如果把滚动条拉到底部的时候点击修改(或者修改后点击更新,取消)页面重新加载的时候都会把滚动条拉到页面最上面部分,特此我将下面知识共享一下:object .scrollIntoView([bAlignToTop])
Parameters
ReturnValue
Remarks
Example
StandardsInformation
AppliesTo
二、在.Net中的应用
1、定位指定控件
///<summary>
///定位txtCode控件
///</summary>
privatevoidScroll()
{
strings="<script>functionwindow.onload(){document.all(""+this.txtCode.ClientID+"").scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}
2、定位指定DataGrid列
<div style="BORDER:0px;PADDING:0px;MARGIN:0px;OVERFLOW:scroll;WIDTH:600px;HEIGHT:200px" align="center">
bAlignToTop Optional.Boolean thatspecifiesoneofthefollowingvalues: true Default.Scrollstheobjectsothattopoftheobjectisvisibleatthetopofthewindow. false Scrollstheobjectsothatthebottomoftheobjectisvisibleatthebottomofthewindow.
Noreturnvalue.
ThescrollIntoViewmethodisusefulforimmediatelyshowingtheusertheresultofsomeactionwithoutrequiringtheusertomanuallyscrollthroughthedocumenttofindtheresult.
Dependingonthesizeofthegivenobjectandthecurrentwindow,thismethodmightnotbeabletoputtheitemattheverytoporverybottom,butwillpositiontheobjectasclosetotherequestedpositionaspossible.
ThisexampleusesthescrollIntoViewmethodtounderlinethecontentofthedocument"sfifthparagraphandscrollitintoviewatthetopofthewindow.
HideExample varcoll=document.all.tags("P"); if(coll.length>=5) { coll(4).style.textDecoration="underline"; coll(4).scrollIntoView(true); }
Thereisnopublicstandardthatappliestothismethod.
INPUTtype=ra... Platform Version Win16: 4.0 Win32: 4.0 Windows CE: 4.0 Unix: 4.0 Mac: 4.0 Versiondataislistedwhenthemousehoversoveralink,orthelinkhasfocus. A,ADDRESS,APPLET,AREA,B,BIG,BLOCKQUOTE,BR,BUTTON,CAPTION,CENTER,CITE,CODE,COL,COLGROUP,COMMENT,controlRange,CUSTOM,DD,DFN,DIR,DIV,DL,DT,EM,EMBED,FIELDSET,FONT,FORM,hn,HR,I,IFRAME,IMG,INPUTtype=button,INPUTtype=checkbox,INPUTtype=file,INPUTtype=image,INPUTtype=password,INPUTtype=radio,INPUTtype=reset,INPUTtype=submit,INPUTtype=text,KBD,LABEL,LEGEND,LI,LISTING,MAP,MARQUEE,MENU,NOBR,OBJECT,OL,P,PLAINTEXT,PRE,S,SAMP,SELECT,SMALL,SPAN,STRIKE,STRONG,SUB,SUP,TABLE,TBODY,TD,TEXTAREA,TextRange,TFOOT,TH,THEAD,TR,TT,U,UL,VAR,WBR,XMP MovethemousepointeroveranelementintheAppliesTolisttodisplayavailabilityinformationforthelistedplatforms.
二、在.Net中的应用
1、定位指定控件
///<summary>
///定位txtCode控件
///</summary>
privatevoidScroll()
{
strings="<script>functionwindow.onload(){document.all(""+this.txtCode.ClientID+"").scrollIntoView();}</script>";
Page.RegisterStartupScript("",s);
}
2、定位指定DataGrid列
现在给出一种简单的办法(其他的一些利用锚点等办法都比较复杂)
写了一个方法,其中DataGrid1换成自己的DataGrid的ID,这个方法传递进去的参数就是行号,也就是e.Item.ItemIndex。
比如在编辑操作的时候会写this.DataGrid1.EditItemIndex=e.Item.ItemIndex;
在此语句的以前加入Scroll(e.Item.ItemIndex);就可以了
同样在更新操作的时候写为Scroll(e.Item.ItemIndex);this.DataGrid1.EditItemIndex=-1;绑定;
相关文章
- SCM供应链系统供应商全生命周期管理,助力建筑材料企业快速定位合适供应商
- 最新|移动机器人导航定位技术概述
- CSS绝对定位7大应用场景实战案例分享
- 【HTML】HTML 标签 ⑤ ( 锚点定位 | base 标签 | 预格式化文本标签 | HTML 特殊符号 )
- mysql死锁问题定位解决
- MySQL查询:精准定位年月(mysql查询年月)
- 的搜索Linux U盘搜索:快速定位文件目录(linuxu盘目录)
- Linux命令Which:定位可执行程序的利器(linux命令which)
- Oracle SQL跟踪神器,轻松定位SQL问题(oracle跟踪sql工具)
- idoracle获取数据行快速定位与删除方法探讨(oracle row)
- Occipital推出VR定位追踪平台 一个摄像头也能实现SteamVR级别的定位?!