按钮拒绝工作

时间:2011-12-18 12:23:35

标签: asp.net button

我有一个标准按钮,应该调用一个方法,但它只是拒绝工作,我无法弄清楚原因。

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>

1 个答案:

答案 0 :(得分:0)

引用: *我刚刚添加了文本框方法*

我想我们试图更新你不能的密码文本框。

仅限于:

PasswordLabel .Attributes["value"] = "aaa";