Page is Scrolling Up When Clicked On Button In ASP.NET

Aug 1 2013 6:55 AM
hi


I Have a Page With 50 Types Of Products Taken In Datalist And For Each Product There I Had Put A Button "Add To Cart".
My Problem Is That When I Click On The Button "Add To Cart" Of A Product, Then The Page Is Scrolling To Top Position Always.
How To Stop The Scrolling Of A Page When Button Is Clicked.. 
Some One Help Me..Thanks In Advance...

The Designing Code I Had Used :

<%@ Page Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" MaintainScrollPositionOnPostback="true"

    CodeFile="Products.aspx.cs" Inherits="Library" Title="Sai TriShakthi Nilayam" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <br />

     <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1"

        DataKeyField="ProductID"

        onselectedindexchanged="DataList1_SelectedIndexChanged" RepeatColumns="3" RepeatDirection="Horizontal"

    BorderColor="#336699" BorderStyle="None" BorderWidth="2px" Width="747px">

            <ItemTemplate>

                <%--ProductID:--%>

                <asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' Visible="false"/>

                <br />

               

                <asp:Label ID="ProductNameLabel" CssClass="class1" runat="server"

                    Text='<%# Eval("ProductName") %>' />

                <br /><br />

                <asp:Image ID="Image1" runat="server" CssClass="class1" ImageUrl='<%# Eval("ProductImage") %>' Height="100" Width="150"/><br />

                <asp:Label ID="ProductImageLabel" runat="server" Text='<%# Eval("ProductImage") %>' Visible="false" /><br />

                <asp:Button ID="lnkSelect" runat="server" CommandName="Select" Text="Add To Cart" />

                Price:

                <asp:Label ID="ProductPriceLabel" runat="server" Text='<%# Eval("ProductPrice") %>' />

                   

                <br />

                <br />

            </ItemTemplate>

            <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />

        </asp:DataList>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">

        </asp:UpdatePanel> 

        <asp:SqlDataSource ID="SqlDataSource1" runat="server"

            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

            SelectCommand="SELECT [ProductID], [TypeOfImage], [ProductName], [ProductDescription], [ProductPrice], [ProductImage] FROM [tblImages] WHERE ([TypeOfImage] = @TypeOfImage) ORDER BY ProductName">

            <SelectParameters>

                <asp:ControlParameter ControlID="DataList1" DefaultValue="Products"

                    Name="TypeOfImage" PropertyName="SelectedValue" Type="String" />

            </SelectParameters>

        </asp:SqlDataSource>

   

</asp:Content>


Answers (12)