Question Button1_Click fires twice?

raysefo

Well-known member
Joined
Jul 21, 2010
Messages
207
Programming Experience
Beginner
Hi,

I have an aspx page like below, when i click Button1 (asp:Button) it fires twice. Any ideas?

Thanks in advance.

Best Regards

VB.NET:
<%@ Page Title="" Language="VB" MasterPageFile="~/Master.master" AutoEventWireup="false"
    CodeFile="pendingApproval.aspx.vb" Inherits="PendingApproval" %>

<%@ Register Src="userinfovb.ascx" TagName="userinfo" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        td div
        {
            height: 200px;
            width: 442px;
            overflow: auto;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="Server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <span class="title">Onay Bekleyenler</span>
    <uc1:userinfo ID="userinfo1" runat="server" />
    <div class="div_content">
        <table class="table" border="1">
            <col class="table_left" />
            <col class="table_right" />
            <tr>
                <td>
                    <div>
                        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
                            EmptyDataText="There are no data records to display." AllowPaging="True" AllowSorting="True"
                            CellPadding="4" ForeColor="#333333" GridLines="None" Style="margin-right: 0px"
                            Width="422px" DataKeyNames="EformID,EformType,TaskID,CreatedBy">
                            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            <Columns>
                                <asp:BoundField DataField="Talebi Yapan" HeaderText="Talebi Yapan" SortExpression="Talebi Yapan">
                                    <ItemStyle Font-Bold="True" ForeColor="Red" HorizontalAlign="Center" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Talep Zamanı" HeaderText="Talep Zamanı" SortExpression="Talep Zamanı"
                                    ReadOnly="True">
                                    <ItemStyle Font-Bold="True" HorizontalAlign="Center" />
                                </asp:BoundField>
                                <asp:BoundField DataField="EForm Adı" HeaderText="EForm Adı" SortExpression="EForm Adı">
                                    <ItemStyle Font-Italic="True" HorizontalAlign="Center" />
                                </asp:BoundField>
                                <asp:BoundField DataField="EformID" HeaderText="EformID" SortExpression="EformID"
                                    Visible="False" />
                                <asp:BoundField DataField="EformType" HeaderText="EformType" SortExpression="EformType"
                                    Visible="False" />
                                <asp:BoundField DataField="TaskID" HeaderText="TaskID" SortExpression="TaskID" Visible="False" />
                                <asp:BoundField DataField="CreatedBy" HeaderText="CreatedBy" SortExpression="CreatedBy"
                                    Visible="False" />
                                <asp:CommandField ButtonType="Button" ShowSelectButton="True">
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:CommandField>
                            </Columns>
                            <EditRowStyle BackColor="#999999" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#E9E7E2" />
                            <SortedAscendingHeaderStyle BackColor="#506C8C" />
                            <SortedDescendingCellStyle BackColor="#FFFDF8" />
                            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                        </asp:GridView>
                    </div>
                </td>
                <td class="style1">
                    <% If (Me.formType = 1) Then%>
                    <div>
                        <asp:FormView ID="eformView" runat="server" DataSourceID="eformdetails" CellPadding="4"
                            ForeColor="#333333" Height="194px" Style="margin-top: 0px" Width="437px">
                            <EditRowStyle BackColor="#999999" />
                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <HeaderTemplate>
                                <%# Eval("Talebi Yapan")%>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <table width="100%" cellpadding="5" align="left" bgcolor="whitesmoke">
                                    <tr>
                                        <td>
                                            <table cellpadding="5">
                                                <tr>
                                                    <td>
                                                        <b>Ödeme Türü:</b>
                                                        <%# Eval("Ödeme Türü")%><br>
                                                        <b>Hesap:</b>
                                                        <%# Eval("Hesaplar")%><br>
                                                        <b>İş Avans Tutarı:</b>
                                                        <%# Eval("İş Avans Tutarı", "{0:#,###}")%><br>
                                                        <b>İş Avans Birimi:</b>
                                                        <%# Eval("İş Avans Birimi")%><br>
                                                        <b>Avans Tarihi:</b>
                                                        <%# Eval("Tarih")%><br>
                                                        <b>Talep Zamanı:</b>
                                                        <%# Eval("Talep Zamanı")%><br>
                                                        <b>Açıklama:</b>
                                                        <%# Eval("Açıklama")%><br>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        </asp:FormView>
                    </div>
                    <%  End If%>
                </td>
            </tr>
            <tr>
                <% If (Me.check = 1) Then%>
                <td>
                </td>
                <td align="center">
                    <asp:Button ID="Button1" runat="server" Text="Onayla" Width="69px" BorderColor="Lime"
                        BorderStyle="Double" Font-Bold="True" Font-Names="Arial" Font-Size="Medium" OnClick="Button1_Click" />
                    <asp:Button ID="Button2" runat="server" BorderColor="Red" BorderStyle="Double" Font-Bold="True"
                        Font-Names="Arial" Font-Size="Medium" Text="Reddet" />
                </td>
                <%  End If%>
            </tr>
        </table>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EFormsConnectionString1 %>"
            ProviderName="<%$ ConnectionStrings:EFormsConnectionString1.ProviderName %>"
            SelectCommand="SELECT Users.name AS 'Talebi Yapan', CONVERT (varchar(20), Tasks.CreationDate, 113) AS 'Talep Zamanı', EformType.EformName as 'EForm Adı', Tasks.EformID, Tasks.EformType, Tasks.TaskID, Tasks.CreatedBy FROM Tasks INNER JOIN EformType ON Tasks.EformType = EformType.EformType INNER JOIN Users ON Tasks.CreatedBy = Users.SAMAccountName WHERE (Tasks.IsApproved = 0) and Tasks.Approver = 'ogoksoy'  ORDER BY Tasks.CreationDate asc">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="eformdetails" runat="server" ConnectionString="<%$ ConnectionStrings:EFormsConnectionString1 %>"
            ProviderName="<%$ ConnectionStrings:EFormsConnectionString1.ProviderName %>"
            SelectCommand="SELECT CASE [OdemeTuru] WHEN 1 THEN 'Nakit' WHEN 2 THEN 'Hesaba
            Havale' END AS 'Ödeme Türü', Eform_IsAvans.Hesaplar, Eform_IsAvans.IsAvansTutari
            AS 'İş Avans Tutarı', Eform_IsAvans.IsAvansBirim AS 'İş Avans Birimi', CONVERT (varchar(10),
            Eform_IsAvans.Tarih, 104) AS Tarih, Eform_IsAvans.Aciklama AS Açıklama, Users.name
            AS 'Talebi Yapan', CONVERT (varchar(20), Eform_IsAvans.CreationDate, 113) AS 'Talep Zamanı' FROM Eform_IsAvans INNER JOIN Tasks ON Eform_IsAvans.EFormID = Tasks.EformID
            INNER JOIN Users ON Eform_IsAvans.CreatedBy = Users.SAMAccountName WHERE Eform_IsAvans.EFormID = @EformID">
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="EformID" PropertyName="SelectedValue"
                    Type="Object" />
            </SelectParameters>
        </asp:SqlDataSource>
        <br />
    </div>
</asp:Content>
 
Back
Top