如何在页面回发上维护div滚动 [英] How to maintain div scrolling on page postback

查看:54
本文介绍了如何在页面回发上维护div滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用updatepanel,在updatepanel中gridview是在div中。 Div有滚动但是当页面渲染时div滚动占据了他的起始位置。



所以我如何在页面渲染中保持Div滚动。



谢谢

Shubham Gupta

Hi,

I am using updatepanel, in updatepanel gridview is in a div. Div have scrolling but when page render div scrolling takes his starting position.

So how i can maintain Div scrolling in page render.

Thanks
Shubham Gupta

推荐答案

if you are using IE then its very simple just put the code in your page directive.

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default"

MaintainScrollPositionOnPostback="true" %>

but it will not work in Firefox for that you have to add one browser file into your website

Right click on solution explorer and Add New Item

Select Browser File and add it to App_Browsers folder.

Add MaintainScrollPositionOnPostback capability to this browser file as written below.

<browsers>
  <browser refID="Mozilla">
      <capabilities>
        <capability name="supportsMaintainScrollPositionOnPostback" value="true" />
    </capabilities>
  </browser>
</browsers>


ok, I have your solution. First use below in .aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MaintainScrollPositionOnPostback="true"%>
now after that put below code in code behind file
protected void Page_Load(object sender, EventArgs e)
{
SmartNavigation = true;
}
now create a default folder of App_Browsers in root directory and add new item, select browser.browser file and set its name like SafariFix.browser and put replace below code
<!--
You can find existing browser definitions at
<windir>\Microsoft.NET\Framework\<ver>\CONFIG\Browsers
-->
<browsers>
<browser id="NewBrowser" parentID="Mozilla">
<identification>
<userAgent match="Unique User Agent Regular Expression" />
</identification>
<capture>
<userAgent match="NewBrowser (?'version'\d+\.\d+)" />
</capture>
<capabilities>
<capability name="browser" value="My New Browser" />
<capability name="version" value="


{version} / >
< / capabilities >
< ; / browser >
< 浏览器 refID = Safari1Plus >
< 功能 >
< 功能 名称 = supportsMaintainScrollPositionOnPostback value = true / >
< / capabilities >
< / browser >
< / browsers >
它将彻底解决您的问题,因为我已经测试过了在所有三个浏览器中
{version}" /> </capabilities> </browser> <browser refID="Safari1Plus"> <capabilities> <capability name="supportsMaintainScrollPositionOnPostback" value="true" /> </capabilities> </browser> </browsers> it will completely solve your problem, because i already tested in all three browsers


这篇关于如何在页面回发上维护div滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆