2012-02-29 59 views
0

好的,所以我有这个页面,其中有一个Ajax:AsyncFileUploader还有一些其他的AJAX东西,如ModelPopUpExtender等。问题是页面中的两个按钮,的CancelSubmit,他们都发射但没有发布回来,而我确保页面中的任何字段都是空白的。asp.net页面没有回复,而按钮点击事件仍在发射

我知道事件正在启动,因为我调试了Firebug中的JavaScript(单步进入并继续进程花费了4分多钟,而我几乎拿着F10键进入,关闭!)

如果有人想代码,请告诉我,我会把它张贴,但按键都只是正常的代码,所以没有什么特别的,这就是为什么我没有张贴的代码,但在需要的情况下,我可以张贴整个页面的代码(这是相当长我会告诉你,不是真的,但至少只是在这里发布的目的,约200线)。 任何帮助任何人?

编辑:根据评论我张贴的代码
代码:aspx页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" 
    Inherits="_Default" %> 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title>Detailed Reminder</title> 
    <link href="StyleSheets/Default.css" rel="stylesheet" type="text/css" /> 

    <script type="text/javascript"> 

     function FileUploaded(sender, args) { 
      var filename = args.get_fileName(); 
      var contentType = args.get_contentType(); 
      var text = "Size of " + filename + " is " + args.get_length() + " bytes"; 
      if (contentType.length > 0) { 
       text += " and content type is '" + contentType + "'."; 
      } 
      $get('LabelStatusUpload').innerHTML = "File Uploaded Successfully"; 
     } 

     function UploadStarted(sender, args) { 
      $get('LabelStatusUpload').innerHTML = "Upload Started"; 
     } 

     function ErrorUploaded(sender, args) { 
      $get('LabelStatusUpload').innerHTML = "Some Error Occured"; 
     } 

    </script> 

</head> 
<body> 
    <form id="Form1" runat="server"> 
    <ajax:ToolkitScriptManager ID="SM1" runat="server"> 
    </ajax:ToolkitScriptManager> 
    <asp:Button ID="Temp1" runat="server" Text="clear" /> 
    <div id="UpperContainer"> 
     <asp:Panel ID="PanelOuter" runat="server"> 
      <asp:Table ID="TableDetailedRemidner" runat="server"> 
       <asp:TableRow ID="TableRowName" runat="server"> 
        <asp:TableCell ID="TableCell1" runat="server"> 
         <asp:Label ID="LabelName" runat="server" AssociatedControlID="txtName" Text="Name"></asp:Label> 
        </asp:TableCell> 
        <asp:TableCell ID="TableCell2" runat="server"> 
         <asp:TextBox ID="txtName" runat="server" ToolTip="Name of the user to send the mail to"></asp:TextBox> 
        </asp:TableCell> 
       </asp:TableRow> 
       <asp:TableRow ID="TableRowEmail" runat="server"> 
        <asp:TableCell ID="TableCell3" runat="server"> 
         <asp:Label ID="LabelEmail" runat="server" AssociatedControlID="txtEmail1" Text="Email 1"></asp:Label> 
        </asp:TableCell> 
        <asp:TableCell ID="TableCell4" runat="server"> 
         <asp:TextBox ID="txtEmail" runat="server" Width="560px"></asp:TextBox> 
         <asp:RegularExpressionValidator ID="regexEmailValidator" runat="server" ControlToValidate="txtEmail" 
          Display="Dynamic" Text="Invalid Email" ValidationExpression="\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator> 
        </asp:TableCell> 
       </asp:TableRow> 
       <asp:TableRow ID="TableRowSubject" runat="server"> 
        <asp:TableCell ID="TableCell5" runat="server"> 
         <asp:Label ID="LabelSubject" runat="server" AssociatedControlID="txtSubject" Text="Subject"></asp:Label> 
        </asp:TableCell> 
        <asp:TableCell ID="TableCell6" runat="server"> 
         <asp:TextBox ID="txtSubject" runat="server" AutoComplete="off" Width="560px"></asp:TextBox> 
         <asp:Panel ID="PanelDefaultSubjects" runat="server"> 
          <div> 
           <asp:UpdatePanel ID="UpdatePanelSubject" runat="server"> 
            <ContentTemplate> 
             <asp:RadioButtonList ID="RadioSubjectList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadioSubjectList_SelectedIndexChanged"> 
              <asp:ListItem Text="Submit the reports"></asp:ListItem> 
              <asp:ListItem Text="prepare the presentation"></asp:ListItem> 
              <asp:ListItem Text="Custom" Value=""></asp:ListItem> 
             </asp:RadioButtonList> 
            </ContentTemplate> 
           </asp:UpdatePanel> 
          </div> 
         </asp:Panel> 
         <ajax:PopupControlExtender ID="PCESubject" runat="server" TargetControlID="txtSubject" 
          PopupControlID="PanelDefaultSubjects" CommitProperty="value" Position="Right" 
          OffsetX="5" CommitScript="e.value" /> 
        </asp:TableCell> 
       </asp:TableRow> 
       <asp:TableRow ID="TableRowMessage" runat="server"> 
        <asp:TableCell ID="TableCell7" runat="server"> 
         <asp:Label ID="LabelMessageBody" runat="server" AssociatedControlID="txtMessageBody" 
          Text="Message"></asp:Label> 
        </asp:TableCell> 
        <asp:TableCell ID="TableCell8" runat="server"> 
         <asp:TextBox ID="txtMessageBody" runat="server" Columns="40" Rows="10" Multiline="true"></asp:TextBox> 
        </asp:TableCell> 
       </asp:TableRow> 
       <asp:TableRow ID="TableRowFileUpload" runat="server"> 
        <asp:TableCell ID="TableCell9" runat="server"> 
         <asp:Label ID="LabelFileAttached" runat="server" AssociatedControlID="AsyncFileUpload1" 
          Text="Attach a file"></asp:Label> 
        </asp:TableCell> 
        <asp:TableCell ID="TableCell10" runat="server"> 
         <ajax:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnClientUploadComplete="FileUploaded" 
          OnClientUploadError="ErrorUploaded" OnClientUploadStarted="UploadStarted" OnUploadedComplete="File_Uploaded" 
          UploaderStyle="Modern" ThrobberID="LabelThobber" /> 
         <asp:Label ID="LabelThobber" runat="server" Style="display: none"><img alt="" src="Images/uploading.gif" /></asp:Label><br /> 
         <asp:Label ID="LabelStatusUpload" runat="server" Text=" "></asp:Label> 
        </asp:TableCell> 
       </asp:TableRow> 
       <asp:TableRow ID="TableRowDueDate" runat="server"> 
        <asp:TableCell ID="TableCell11" runat="server"> 
         <asp:Label ID="LabelDueDate" runat="server" AssociatedControlID="txtDueDate" Text="Due Date"></asp:Label> 
        </asp:TableCell> 
        <asp:TableCell ID="TableCell12" runat="server"> 
         <asp:TextBox ID="txtDueDate" runat="server" Width="560px"></asp:TextBox> 
         <ajax:MaskedEditExtender runat="server" ID="MEEDueDate" TargetControlID="txtDueDate" 
          Mask="99/99/9999" AutoComplete="true" MaskType="Date"> 
         </ajax:MaskedEditExtender> 
         <ajax:MaskedEditValidator ID="MEVDueDate" runat="server" ControlExtender="MEEDueDate" 
          ControlToValidate="txtDueDate" IsValidEmpty="False" EmptyValueMessage="Due Date is required" 
          InvalidValueMessage="Due Date is required" EmptyValueBlurredText="*" InvalidValueBlurredMessage="*" 
          MaximumValueBlurredMessage="*" MinimumValueBlurredText="*" Display="Dynamic" /> 
         <ajax:CalendarExtender ID="CalDueDate" runat="server" TargetControlID="txtDueDate"> 
         </ajax:CalendarExtender> 
        </asp:TableCell></asp:TableRow> 
       <asp:TableRow ID="TableRowFrequency" runat="server"> 
        <asp:TableCell ID="TableCell17" runat="server"> 
         <asp:Label ID="LabelFrequency" runat="server" AssociatedControlID="txtFrequency" 
          Text="Frequency"></asp:Label> 
        </asp:TableCell><asp:TableCell ID="TableCell18" runat="server"> 
         <asp:TextBox ID="txtFrequency" runat="server"></asp:TextBox> 
         <asp:Panel ID="PanelFrequency" runat="server"> 
          <div> 
           <asp:UpdatePanel ID="UpdatePanelFrequency" runat="server"> 
            <ContentTemplate> 
             <asp:RadioButtonList ID="RadioButtonFrequency" runat="server" AutoPostBack="true" 
              OnSelectedIndexChanged="RadioSubjectFrequency_SelectedIndexChanged"> 
              <asp:ListItem Text="15 min"></asp:ListItem> 
              <asp:ListItem Text="6 hr"></asp:ListItem> 
              <asp:ListItem Text="24 hr"></asp:ListItem>> 
             </asp:RadioButtonList> 
            </ContentTemplate> 
           </asp:UpdatePanel> 
          </div> 
         </asp:Panel> 
         <ajax:PopupControlExtender ID="PCEFrequency" runat="server" TargetControlID="txtFrequency" 
          PopupControlID="PanelFrequency" CommitProperty="value" Position="Right" OffsetX="5" 
          CommitScript="e.value" /> 
        </asp:TableCell></asp:TableRow> 
       <asp:TableFooterRow> 
        <asp:TableCell ID="TableCellSubmit" runat="server"> 
         <asp:Button ID="BtnSubmit" runat="server" OnClick="Submit_Click" Text="Set Reminder Detailed" /> 
        </asp:TableCell><asp:TableCell ID="TableCellCancel" runat="server"> 
         <asp:Button ID="BtnCancel" runat="server" OnClick="Cancel_Click" Text="Cancel" /> 
        </asp:TableCell></asp:TableFooterRow> 
      </asp:Table> 
     </asp:Panel> 
    </div> 
    </form> 
</body> 
</html> 

代码:page_Behind.aspx.cs

using System; 
using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
using System.IO; 

public partial class _Default : System.Web.UI.Page 
{ 
    //static protected string savePath; 
    //static protected int curFileSize; 
    //static protected bool IsFileAttached; 

    protected void Page_Load(object sender, EventArgs e) 
    { 
     CalDueDate.StartDate = DateTime.Now.Date; 
     CalDueDate.EndDate = DateTime.Now.Date.AddYears(1); 
     MEVDueDate.MinimumValue = DateTime.Now.Date.ToShortDateString(); 
     MEVDueDate.MaximumValue = DateTime.Now.Date.ToShortDateString(); 
    } 

    protected void RadioSubjectList_SelectedIndexChanged(object sender, EventArgs e) 
    { 
     if (!string.IsNullOrEmpty(RadioSubjectList.SelectedValue)) 
     { 
      // Popup result is the selected task 
      PCESubject.Commit(RadioSubjectList.SelectedValue); 
     } 
     else 
     { 
      // Cancel the popup 
      PCESubject.Cancel(); 
     } 
     // Reset the selected item 
     RadioSubjectList.ClearSelection(); 
    } 

    protected void RadioSubjectFrequency_SelectedIndexChanged(object sender, EventArgs e) 
    { 
     if (!string.IsNullOrEmpty(RadioButtonFrequency.SelectedValue)) 
     { 
      PCEFrequency.Commit(RadioButtonFrequency.SelectedValue); 
     } 
     else 
     { 
      PCEFrequency.Cancel(); 
     } 
     RadioButtonFrequency.ClearSelection(); 
    } 

    protected void File_Uploaded(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) 
    { 
     if (AsyncFileUpload1.HasFile) 
     { 
      string savePath = MapPath("~/Uploads/") + Path.GetFileName(DateTime.Now.Month + DateTime.Now.Day + " " 
                      + DateTime.Now.Hour + DateTime.Now.Minute + " " + e.FileName); 
      AsyncFileUpload1.SaveAs(savePath); 
     } 
    } 

    protected void Submit_Click(object sender, EventArgs e) 
    { 
     // On Submit button doesn't even reaches here, debugged and breakpoint on any of following code is never reached 
     int lastID = BusinessLayer.DetermineLastDetailedID(); 
     // Some other logic unimportant at this point 
     BusinessLayer.AddDReminder(sender, e); 
    } 

    protected void Cancel_Click(object sender, EventArgs e) 
    { 
     txtName.Text = ""; 
     txtEmail1.Text = ""; 
     txtEmail2.Text = ""; 
     txtEmail3.Text = ""; 
     txtSubject.Text = ""; 
     txtMessageBody.Text = ""; 
     txtDueDate.Text = ""; 
     txtFrequency.Text = ""; 

    } 

} 
+3

的ASPX代码和代码隐藏将是有益的 - 否则,任何的答案是纯粹的投机IMO ...... – Yahia 2012-03-02 19:12:12

+1

你有更新面板的心不是?这就是为什么该页面不回发。 – PraveenVenu 2012-03-04 07:10:36

+0

@Yahia: 根据你的建议,我已经添加了代码,也许你可以看看并帮我弄清楚什么是错的? – Razort4x 2012-03-04 19:59:07

回答

1

我复制了你的代码,遇到了这个问题,修复了它,现在回发正好发生。 MEVDueDate总是说“IsValid = false”,并且因为PostBack没有进入Page_Load(这是验证器的预期行为)。

你需要改变:

MEVDueDate.MinimumValue = DateTime.Now.Date.ToShortDateString(); 
MEVDueDate.MaximumValue = DateTime.Now.Date.ToShortDateString(); 

本:

MEVDueDate.MinimumValue = DateTime.Now.Date.ToString("MM/dd/yyyy"); 
MEVDueDate.MaximumValue = DateTime.Now.Date.ToString("MM/dd/yyyy"); 

今天在日历上选择的截止日期,点击取消按钮,你应该有一个完整的回发。请注意,你所说的最小和最大允许日期都是今天的,所以今天是唯一有效的日期,可以让后卫开火。

的原因是你的日历选择的文本框“03/08/2012”,但ToShortDateString()写道检索与另一个日期格式的字符串。你最终比较“03/08/2012”和“08/03/2012”。

您需要确保您用来设置MEVDueDate.MinimumValue的日期格式是根据calendarPicker(CalDueDate)放入txtDueDate的格式。

0
comment this and try 



    <%-- <ajax:MaskedEditExtender runat="server" ID="MEEDueDate" TargetControlID="txtDueDate" 
         Mask="99/99/9999" AutoComplete="true" MaskType="Date"> 
        </ajax:MaskedEditExtender> 
        <ajax:MaskedEditValidator ID="MEVDueDate" runat="server" ControlExtender="MEEDueDate" 
         ControlToValidate="txtDueDate" IsValidEmpty="False" EmptyValueMessage="Due Date is required" 
         InvalidValueMessage="Due Date is required" EmptyValueBlurredText="*" InvalidValueBlurredMessage="*" 
         MaximumValueBlurredMessage="*" MinimumValueBlurredText="*" Display="Dynamic" /> 
        <ajax:CalendarExtender ID="CalDueDate" runat="server" TargetControlID="txtDueDate"> 
        </ajax:CalendarExtender>--%> 
0

按钮事件不是道具agated,他们是表中包含的对象。

注册在创建表的2个按钮的onclick事件。