关于页面定位问题
如下例,每次单击展开,关闭后页面自动定位到了页头,怎样才能让其单击展开,关闭后让其位置还是停留在选择的行,而不是跑到页头去了,希望高手点拨!<%@ Page Language="VB" %>
<%@ import Namespace ="System.Web.UI.Page" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand
If e.CommandName = "dopen" Then
'当单击的是[展开]链接时,显示详细信息
DataList1.SelectedIndex = e.Item.ItemIndex
DataList1.DataBind()
ElseIf e.CommandName = "dclose" Then
'当单击的是[关闭]链接时,关闭详细信息
DataList1.SelectedIndex = -1
DataList1.DataBind()
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server" method="post">
<div>
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="DataList1_ItemCommand">
<ItemTemplate>
WORKNO:
<asp:Label ID="WORKNOLabel" runat="server" Text='<%# Eval("WORKNO") %>'></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="dopen">展开</asp:LinkButton><br />
<br />
</ItemTemplate>
<SelectedItemTemplate>
CUSTNAME:
<asp:Label ID="CUSTNAMELabel" runat="server" Text='<%# Eval("CUSTNAME") %>'></asp:Label><br />
COUNTRY:
<asp:Label ID="COUNTRYLabel" runat="server" Text='<%# Eval("COUNTRY") %>'></asp:Label><br />
CTN:
<asp:Label ID="CTNLabel" runat="server" Text='<%# Eval("CTN") %>'></asp:Label><br />
DO_NO:
<asp:Label ID="DO_NOLabel" runat="server" Text='<%# Eval("DO_NO") %>'></asp:Label><br />
BL_NO:
<asp:Label ID="BL_NOLabel" runat="server" Text='<%# Eval("BL_NO") %>'></asp:Label><br />
WKDEL_DELIVERYDATE:
<asp:Label ID="WKDEL_DELIVERYDATELabel" runat="server" Text='<%# Eval("WKDEL_DELIVERYDATE") %>'>
</asp:Label><br />
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="dclose">关闭</asp:LinkButton>
</SelectedItemTemplate>
</asp:DataList></div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString3 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString3.ProviderName %>" SelectCommand="SELECT "WORKNO", "CUSTNAME", "COUNTRY", "CTN", "DO_NO", "BL_NO", "WKDEL_DELIVERYDATE" FROM "WKDEL" where "WKDEL_DELIVERYDATE"=to_date('2007-7-30','YYYY-MM-DD')">
</asp:SqlDataSource>
</form>
</body>
</html>
--------------------编程问答-------------------- 用Html中的锚吧 --------------------编程问答-------------------- 此问题已解决!感谢 青青月儿 MSDN
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'Page.SmartNavigation = True '防止回发回滚 此方案已过时
Page.MaintainScrollPositionOnPostBack = True '2005中防止回发回滚
End Sub
补充:.NET技术 , ASP.NET