Кнопка отказывается работать - PullRequest
0 голосов
/ 18 декабря 2011

У меня есть стандартная кнопка, которая должна вызывать метод, но он просто отказывается работать, и я не могу понять, почему.

ASP код:

<asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button 
            ID="UploadButton" runat="server" onclick="UploadButton_Click" Text="Change Logo" />

Код:

protected void UploadButton_Click(object sender, EventArgs e)
        {
            PasswordLabel.Visible = true;
            PasswordLabel.Text = "TEST Before";
            Image_Inserting(this);
            PasswordLabel.Text = "TEST After";

        }

Я только что добавил методы текстового поля, чтобы проверить его, но он, похоже, не отправляет обратно (даже когда я удаляю вызов Image_Inserting). Все остальные кнопки работают нормально, поэтому я не знаю, почему эта кнопка не будет работать.

РЕДАКТИРОВАТЬ: вся страница - код кнопки внизу

<%@ Page Title="" Language="C#" MasterPageFile="~/Standardmaster.Master" AutoEventWireup="true" CodeBehind="VendorAccount.aspx.cs" Inherits="PetShopParadise.Vendor_Pages.VendorAccount" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style10
        {
            color: #FF0000;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">

    <h2>Account Details</h2>

    <div id="RegistrationDiv">
        <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
            <EditItemTemplate>
                Name:
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
                <br />
                Address:
                <asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
                <br />
                Phone_Number:
                <asp:TextBox ID="Phone_NumberTextBox" runat="server" 
                    Text='<%# Bind("Phone_Number") %>' />
                <br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                    CommandName="Update" Text="Update" />
                &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </EditItemTemplate>
            <InsertItemTemplate>
                Name:
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
                <br />
                Address:
                <asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
                <br />
                Phone_Number:
                <asp:TextBox ID="Phone_NumberTextBox" runat="server" 
                    Text='<%# Bind("Phone_Number") %>' />
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                    CommandName="Insert" Text="Insert" />
                &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
            <ItemTemplate>
                Name:
                <asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
                <br />
                Address:
                <asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>' />
                <br />
                Phone Number:
                <asp:Label ID="Phone_NumberLabel" runat="server" 
                    Text='<%# Bind("Phone_Number") %>' />
                <br />
                    <asp:Button ID="Button3" runat="server" Text="Edit Details" CommandName="Edit" />
                    <br />

            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PetShopParadiseConnectionString %>" 
            SelectCommand="SELECT [Name], [Address], [Phone_Number] FROM [Vendors] WHERE ([VendorID] = @VendorID)">
            <SelectParameters>
                <asp:SessionParameter Name="VendorID" SessionField="ID" Type="Decimal" />
            </SelectParameters>
        </asp:SqlDataSource>
                    <br />
        <asp:Table ID="Table1" runat="server" style="text-align:left;">
            <asp:TableRow ID="TableRow4" runat="server">
                <asp:TableCell ID="TableCell7" runat="server">Password</asp:TableCell><asp:TableCell ID="TableCell8" runat="server">
                    <asp:TextBox ID="PasswordBox" TextMode="Password" runat="server"></asp:TextBox>
                     <asp:RequiredFieldValidator
                        id="RequiredFieldValidator5"
                        runat="server"
                        ControlToValidate="PasswordBox"
                        Display="None"
                        Forecolor="Red"
                        ErrorMessage="Please enter a password." />
                        </asp:TableCell></asp:TableRow><asp:TableRow ID="TableRow5" runat="server">
                <asp:TableCell ID="TableCell9" runat="server">Re-Enter Password</asp:TableCell><asp:TableCell ID="TableCell10" runat="server">
                    <asp:TextBox ID="PasswordCheckBox" TextMode="Password" runat="server"></asp:TextBox>
                     <asp:RequiredFieldValidator
                        id="RequiredFieldValidator6"
                        runat="server"
                        ControlToValidate="PasswordCheckBox"
                        Display="None"
                        Forecolor="Red"
                        ErrorMessage="Please re-enter your password." />
                    </asp:TableCell></asp:TableRow></asp:Table><asp:Label 
            ID="PasswordLabel" runat="server" Text="Password" CssClass="style10"></asp:Label><br />
                    <asp:Button ID="PasswordButton" 
            runat="server" Text="Update Password" onclick="PasswordButton_Click" /><br />


            <asp:SqlDataSource 
            ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PetShopParadiseConnectionString %>" 
            onselecting="SqlDataSource2_Selecting" SelectCommand="SELECT * FROM Vendors" 
            UpdateCommand="UPDATE [Vendors] SET [Password]=@passwordhash WHERE ([VendorID] = @VendorID)" OnUpdating="Parameters_Updating">
            <UpdateParameters>
            <asp:Parameter Name="Password" />
            <asp:SessionParameter name="VendorID" sessionfield="ID" />
            </UpdateParameters>
            </asp:SqlDataSource>

            <br /><asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button 
            ID="UploadButton" runat="server" onclick="UploadButton_Click" Text="Change Logo" /></div></asp:Content>



                    <asp:Content ID="Content3" ContentPlaceHolderID="bannerContent" runat="server">
</asp:Content>

Ответы [ 2 ]

1 голос
/ 18 декабря 2011

Я предполагаю, что это вызывает другую (возможно скрытую) проверку. Убедитесь, что для CausesValidation установлено значение false .

0 голосов
/ 18 декабря 2011

цитата: * Я только что добавил методы текстового поля *

Я думаю, что мы пытаемся обновить текстовое поле пароля, которое вы не можете.

только путем:

PasswordLabel .Attributes["value"] = "aaa";
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...