页面上的所有事件都已停止触发

时间:2015-01-06 10:44:08

标签: c# asp.net events

在这里绝望的高峰期。我离开了两个星期的假期,一个工作项目几乎在发布时我已经回到了问题。

使用Visual Studio 2010,C#用于.Net(3.5)Web项目。

我有两种形式(几乎相同)

  1. 创建文档并将数据存储在数据库中
  2. 数据从数据库加载并被操作
  3. 两种表格都包含许多事件(下面提供的代码)

    表单上有许多用于触发以下对象的事件

    • 文本框tbPartNumber - OnTextChanged
    • 列表框lstbEmailSelectFrom - OnSelectedIndexChanged
    • 列表框lstbEmailSelected - OnSelectedIndexChanged

    所有活动背后的代码都存在,我知道并没有改变。

    我知道他们一次又一次地检查了他们,然后向相关团队的团队负责人展示了这个项目。

    经过一段美好的休息后,我回到了办公室,没有一个休息时间会开火。第二种形式仍按预期运作。

    我不记得在我离开之前做了任何改变,所以我不知所措。

    我今天早上尝试在表单中添加一个新对象,但它不会触发

    <asp:DropDownList ID = "ddlItemList"
                      runat                  = "server"
                      BorderStyle            = "None"
                      BorderColor            = "White"
                      Height                 = "99%"
                      Width                  = "48%"
                      AutoPostBack           = "true"
                      onselectedindexchanged = "ddlItemList_SelectedIndexChanged" >
    </asp:DropDownList>
    

    后面的代码

    protected void ddlItemList_SelectedIndexChanged(object sender, EventArgs e)
      {
      OleDbConnection con = new OleDbConnection(odbcString);
      OleDbCommand cmd = new OleDbCommand();
    
      string theLanguage = Session["Language"].ToString();
    
      if (Session["UserEmail"] == null)
        { // Session has timed out so get the user to log back in
        ........
        }
      else
        { // Still have the session data
          // Get the list of items for the item box
    
        try
          {
          ......
          }  // Try
        catch (Exception ex)
         {
         ......
         }  // Catch
        }
      }
    

    有没有人的想法?我很感激能得到的任何帮助。


    <%@ Page Language="C#" 
             AutoEventWireup="true" 
             CodeBehind="ConcessionDocument.aspx.cs" 
             Inherits="XXXXXXXXQualityPortal.ConcessionDocument" %>
    
    <%@ Register Assembly="AjaxControlToolkit" 
                 Namespace="AjaxControlToolkit" 
                 TagPrefix="asp" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <%@ Register Assembly="AjaxControlToolkit" 
                 Namespace="AjaxControlToolkit" 
                 TagPrefix="asp" %>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head id="Head1" 
            runat="server">
        <title>
          Tokheim Quality Portal : Concession Document
        </title>
      </head>
      <body>
        <form id="form1" 
              runat="server"
              defaultfocus="tbPartNumber" >
          <div>
    
            <center>
              <asp:Table ID = "tblConcession"
                         runat = "server"
                         width = "85%"
                         BorderWidth = "1"
                         GridLines="Both">
    
    
                <asp:TableRow>
                  <asp:TableCell HorizontalAlign = "Left"
                                 BackColor       = "#E6E0F8">
                    <asp:Label ID    = "lblPartNumber"
                               runat = "server"
                               Text  = "Part Number">
                    </asp:Label>
                  </asp:TableCell>
    
    
    
    
                  <asp:TableCell HorizontalAlign = "Left">
    
                    <!-- **************************************************************** -->
                    <!--                      Problem With this event                     -->
                    <!-- **************************************************************** -->
    
                    <asp:DropDownList ID                     = "ddlItemList"
                                      runat                  = "server"
                                      BorderStyle            = "None"
                                      BorderColor            = "White"
                                      Height                 = "99%"
                                      Width                  = "48%"
                                      AutoPostBack           = "true"
                                      onselectedindexchanged = "ddlItemList_SelectedIndexChanged" >
                    </asp:DropDownList>
    
    
    
    
    
                    &nbsp;
                    <asp:Textbox ID              = "tbPartNumber"
                                 runat           = "server"
                                 AutoPostBack    = "true"
                                 OnTextChanged   = "tbPartNumber_TextChanged"
                                 Height          = "99%"
                                 Width           = "48%">
                    </asp:Textbox>
                    &nbsp;
                    <asp:Label ID     = "lblPartDescription"
                               runat  = "server"
                               Text   = ""
                               Height = "99%">
                    </asp:Label>
    
                  </asp:TableCell>
    
                  <asp:TableCell HorizontalAlign = "Left"
                                 BackColor       = "#E6E0F8">
                    <asp:Label ID    = "lblQuantity"
                               runat = "server"
                               Text  = "Quantity">
                    </asp:Label>
                  </asp:TableCell>
                  <asp:TableCell HorizontalAlign = "Left">
                    <asp:Textbox ID              = "tbQuantity"
                                 BorderStyle     = "None"
                                 BorderColor     = "White"
                                 runat           = "server"
                                 Height          = "99%"
                                 Width           = "99%">
                    </asp:Textbox>
                  </asp:TableCell>
    
                  <asp:TableCell HorizontalAlign = "Left"
                                 BackColor="#E6E0F8">
                    <asp:Label ID    = "lblItemrevision"
                               runat = "server"
                               Text  = "Item Revision">
                    </asp:Label>
                  </asp:TableCell>
                  <asp:TableCell HorizontalAlign = "Left">
                    <asp:Textbox ID = "tbItemrevision"
                                 BorderStyle = "None"
                                 BorderColor = "White"
                                 runat = "server"
                                 Height = "99%"
                                 Width = "99%">
                    </asp:Textbox>
                  </asp:TableCell>
                </asp:TableRow>
    
    
    
                <asp:TableRow>
                  <asp:tableCell ColumnSpan = "6"
                                 HorizontalAlign="Center" >
    
                    <asp:Table ID = "tblEmailBoxes"
                               runat = "server"
                               width = "99%"
                               BorderWidth = "0"
                               GridLines="None">
                      <asp:TableRow>
    
                        <asp:TableCell HorizontalAlign="Center"
                                       width = "45%">
                          <asp:Label ID    = "lblSelectEmailAddress"
                                     runat = "server"
                                     Font-Bold = "true"
                                     Text  = "Select An Email Address For The Distribution List">
                          </asp:Label>
    
                      <!-- **************************************************************** -->
                          <!--                      Problem With this event                     -->
                          <!-- **************************************************************** -->
    
                          <asp:ListBox ID = "lstbEmailSelectFrom"
                                       runat = "server"
                                       AutoPostBack = "true"
                                       OnSelectedIndexChanged="MoveToListBox2"
                                       SelectionMode = "Multiple"
                                       width = "99%">
                          </asp:ListBox>
    
    
    
                        </asp:TableCell>
                        <asp:TableCell HorizontalAlign="Center"
                                       width = "10%">
                          <asp:Button ID = "btnMoveRight"
                                      runat = "Server"
                                      Text = ">" 
                                      visible = "false"
                                      onclick="btnMoveRight_Click" />
                          <br />
                          <asp:Button ID = "btnMoveLeft"
                                      visible = "false"
                                      runat = "Server"
                                      Text = "<" />
                        </asp:TableCell>
                        <asp:TableCell HorizontalAlign="Center"
                                       width = "45%">
                          <asp:Label ID    = "lblEmailAddressesSelected"
                                     runat = "server"
                                     Font-Bold = "true"
                                     Text  = "Email Addresses Selected For The Distribution List">
                          </asp:Label>
    
                      <!-- **************************************************************** -->
                          <!--                      Problem With this event                     -->
                          <!-- **************************************************************** -->
    
                          <asp:ListBox ID = "lstbEmailSelected"
                                       runat = "server"
                                       AutoPostBack = "true"
                                       OnSelectedIndexChanged="MoveToListBox1"
                                       SelectionMode = "Multiple"
                                       width = "99%">
                          </asp:ListBox>
                        </asp:TableCell>
                       </asp:TableRow>
    
                      <asp:TableRow>
                        <asp:TableCell HorizontalAlign="Center"
                                       width = "45%"
                                       ColumnSpan = "3" >
                          <center>
                            <asp:Button ID = "btnSubmit"
                                        runat = "server" 
                                        text = "Submit"
                                        OnClick="btnSubmit_Clicked"/>
    
                          </center>
                        </asp:TableCell>
                       </asp:TableRow>
    
    
                      </asp:Table>
    
    
                  </asp:tableCell>
                </asp:TableRow>
              </asp:Table>        
    
              <center>
    
                    <asp:FileUpload ID="FileUpload1" 
                                    runat="server" 
                                    Height="35px" 
                                    Width="406px" />
                    &nbsp;
                    <asp:Button ID="btnFileLoadPostback" 
                                runat="server" 
                                Text="Load File" 
                                onclick="btnFileLoadPostback_Click" Height="35px" Width="131px" />
    
                  <br />
                  <asp:Image id       = "Image7"
                             ImageUrl = "~/Images/indicator3.png"
                             Style    = "display:None"
                             runat    = "server" />
    
              </center>
    
    
    
              <asp:Label ID    = "theFileList"
                         runat = "server"
                         Text  = ""
                         visible = "false">
              </asp:Label>
    
            </center>
          </div>
        </form>
      </body>
    </html>
    

4 个答案:

答案 0 :(得分:1)

我找到了问题的根源。

我添加了一个注册来关闭一个窗口,看起来这已经禁用了表单上的所有事件。如果我删除它全部工作(除了窗口没有关闭)

protected void Page_Load(object sender, EventArgs e) 
  { 
  if (!IsPostBack) 
    { 
    Page.ClientScript.RegisterOnSubmitStatement(typeof(Page), "closePage", "window.onunload = CloseWindow();"); 
    }
  } 

删除了注册,一切正常

答案 1 :(得分:0)

可能的解决方案:

  1. 清理解决方案并重建。
  2. 检查表单视图是否为cs文件后面的所需代码。

答案 2 :(得分:0)

您是否可能更改了ASPX页面标题中的命名空间或某些内容,导致未正确连接的内容?部署页面的DLL版本不正确?如上所述,干净和重新部署是最好的起点。

答案 3 :(得分:0)

添加内部

<system.web> <compilation debug="true" targetFramework="3.5"/> </system.web>

和Rebuild项目希望它能解决你的问题