ASP.NET 2.0中新增加了2个很实用的属性和方法

ASP.NET 2.0中新增加了2个很实用的属性和方法:

SetFocus()用来将光标聚焦到某个页面控件上
<%@ page language="C#" %>

<script runat="server">
    
void Page_Init(object sender, EventArgs e)
    
{
        SetFocus(focusHere);
    }

</script>

<html>
<head id="Head1" runat="server">
    
<title>Untitled Page</title>
</head>
<body>
    
<form id="form1" runat="server">
        
<asp:textbox id="default" runat="server" /><br />
        
<asp:textbox id="focusHere" runat="server" />
    
</form>
</body>
</html>


MaintainScrollPositionOnPostback 设置成true可以在页面PostBack的时候保持页面滚动条的位置

在web.config作如下设置即可:
<pages smartNavigation="true" maintainScrollPositionOnPostBack="true"/>
原文地址:https://www.cnblogs.com/skyblue/p/808364.html