AutoPostBack控件刷新页面 [英] AutoPostBack Controls refresh the page
问题描述
我有一个很大的形式,有很多问题供用户回答。几乎所有的控件都是AutoPostBack,因为根据他们的答案启用/禁用了一些其他控件。但是如果我假设我单击一个带有AutoPostBack On的单选按钮,页面会按原样重新加载,但是将我带到顶部,然后我向下滚动以回答下一个问题。怎么避免呢?这是一个很长的形式,我想给用户带来不便....
I have a very big form with lots of questions for the user to answer. Almost all of the controls are AutoPostBack as some other controls are enabled/disabled depending on thier answers. But if suppose I click on a radiobutton with AutoPostBack On, the page reloads as it should, but takes me to the top and then I have scroll back down to answer the next question. How to avoid that? It's a long form and I want theleast inconvenience to the user....
推荐答案
你有两个选择
1]使用更新面板喜欢: -
you have two options
1] use update panel like:-
<asp:UpdatePanel ID="updpnlRefresh" runat="server" UpdateMode="Conditional">
<ContentTemplate>
//your controls
</ContentTemplate>
</asp:UpdatePanel>
并在以下任何操作上更新: - updpnlRefresh.Update()
或
2]使用
and update it on any action like:- updpnlRefresh.Update()
Or
2] use
MaintainScrollPositionOnPostback="true"
在你的aspx页面(页面指令)
喜欢
in your aspx page (page directive)
like
<%@ Page Title="Detail" Language="VB" MasterPageFile="~/Site.master"
AutoEventWireup="false" CodeFile="Detail.aspx.vb" Inherits="Detail_Page"
MaintainScrollPositionOnPostback="true" %>
只需粘贴MaintainScrollPositionOnPostback = true在页面指令中。
Just paste MaintainScrollPositionOnPostback="true" in page directive.
<%@ Page Title="ABC" Language="C#" MasterPageFile="~/ABC.master" AutoEventWireup="true"
CodeFile="Lesson.aspx.cs" Inherits="Lesson" ValidateRequest="false" MaintainScrollPositionOnPostback="true" %>
使用
<%@ Page MaintainScrollPositionOnPostback="true" %>
。多数民众赞成。
问候..:)
in your page directive. Thats it.
Regards..:)
这篇关于AutoPostBack控件刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!