为什么按钮在数据列表内单击时滚动条会向上移动? [英] Why on button click inside a datalist the scroll bar goes upwards?

查看:108
本文介绍了为什么按钮在数据列表内单击时滚动条会向上移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的购物车项目中,我有一个包含2列和30行的数据列表。每个产品都有一个

'addtocart'按钮。单击按钮时,当用户滚动鼠标

以查看其他行中的其他项目时,垂直滚动条会向上移动到已经点击的产品。这似乎是因为'addtocart'按钮点击事件。如何停止

这个滚动动作?我也在更新面板中保留了这个addtocart按钮。







<%@ Page Language =C#MasterPageFile =〜/ MasterPage.master AutoEventWireup =trueCodeFile =DT.aspx.csInherits =DTTitle =Untitled PageMaintainScrollPositionOnPostback =true%>



In my shopping cart project, I have a datalist with 2 columns and 30 rows. There is an
'addtocart' button for each product. When a button is clicked, and when the user rolls his mouse
to view other items in other rows, the vertical scroll bar moves upwards towards that already
clicked product. It seems it happens because of that 'addtocart' button click event. How to stop
this scroll movement? I have kept this 'addtocart' button inside an update panel too.



<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="DT.aspx.cs" Inherits="DT" Title="Untitled Page" MaintainScrollPositionOnPostback="true" %>

<asp:UpdatePanel ID="dd" runat="server" >
  <ContentTemplate>
  <asp:TextBox ID="AddToCartTB"  runat = "server" Text='1' BackColor=GhostWhite style=" margin-left:11px" Width="34px"  > </asp:TextBox>
  <asp:Button ID="AddToCart"  runat = "server" Text='Add to Cart'  ForeColor="#333333"  BackColor="#ffcc66" Width="100px"  Style=" margin-top:-22px; margin-left:100px; font-family:Arial"  commandname="myevent">
  </asp:Button>
  </ContentTemplate>
  </asp:UpdatePanel>

推荐答案

这篇关于为什么按钮在数据列表内单击时滚动条会向上移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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