按钮拒绝工作

按钮拒绝工作

问题描述:

我有一个标准的按钮应该调用一个方法,但它只是拒绝工作,我不明白为什么。按钮拒绝工作

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"; 

     } 

我刚添加的文本框方法来测试它,但它似乎并没有被回发(甚至当我删除I​​mage_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][email protected] 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> 
+0

你在页面上是否有一些JS: – 2011-12-18 12:25:57

+0

尝试使用调试器而不是使用TextBox输出。如果您在上述方法中放置断点,或者Debug.Write(“...”)是否在Visual Studio的输出窗口中看到任何内容? – 2011-12-18 12:27:02

+0

PasswordLabel是什么类型?它是密码文本框?请更新。 – 2011-12-18 12:27:12

我的猜测是,它是造成其他(可能是隐藏的)验证运行。请务必设置原因验证虚假

+0

因为它没有注册点击,你可以假设JS阻塞。 – naspinski 2011-12-18 13:08:49

+0

这样做,非常感谢。我可以问一个按钮如何隐藏验证? (仍然是新的ASP,仍然找出扭曲) – Matt 2011-12-18 13:11:03

+0

Asp.Net WebForms是一个奇怪的怪物...有时可以隐藏的意见,仍然验证,因为整个页面在一种形式。例如,表单仍包含上面的所有更新标记,因此表单中的按钮将验证该表单,除非您明确表示不要。我对你的爱好,去Asp.Net MVC,永不回头:)你的生活会更容易(和更高的薪水...)。 – naspinski 2011-12-18 13:14:55

报价整体PAGE-按钮代码: *我刚添加的文本框方法*

我想我们试图更新密码的textBox你不能。

只有:

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

这只是一个正常的标签,我使用调试器来查看它是否真的进入了方法,但它似乎没有注册鼠标点击并调用方法。 – Matt 2011-12-18 12:35:50

+0

你可以上传整个页面指令的顶部线? – 2011-12-18 12:37:23

+0

好的,感谢您的帮助。 – Matt 2011-12-18 12:44:20