2013-03-19 68 views
-2

在我的代码为每个droup下来更新panel.it不回发。对于每个按钮单击完整回发是发生。但我的按钮在更新panel.i尝试触发asynpostback,在这种情况下,服务器端消息不显示。我也想要那个味精。按钮位于更新面板内。但每个按钮点击整页回发

我的代码是:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> 
    <form id="form1" runat="server"> 
    <asp:ScriptManager ID="ScriptManager1" runat="server"> 
    </asp:ScriptManager> 
    <table align="center" style="border: thin solid #FF0000" width="80%"> 
     <tr> 
      <th colspan="2" align="center" bgcolor="Black" style="color: #FFFFFF"> 
       Schedule New Batch 
      </th> 
     </tr> 
     <tr> 
      <td colspan="2" align="center"> 
       <div> 
        <asp:Label ID="lblError" runat="server" Style="font-weight: 700; color: #FF0000;" 
         Text="Label" Visible="False"></asp:Label> 
        <asp:Label ID="lblSucess" runat="server" Style="font-weight: 700; color: #006600; 
         background-color: #FFFFFF;" Text="Label" Visible="False"></asp:Label> 
       </div> 
      </td> 
     </tr> 
     <tr> 
      <td colspan="2"> 
       &nbsp; 
      </td> 
     </tr> 
     <tr> 
      <td class="style44" align="right"> 
       Technology<span class="style23">*</span> : 
      </td> 
      <td class="style45"> 
       <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
        <ContentTemplate> 
         <asp:DropDownList ID="ddlTechnology" runat="server" Width="155px" Class="valid" OnSelectedIndexChanged="ddlTechnology_SelectedIndexChanged" 
          AutoPostBack="True" Height="23px"> 
         </asp:DropDownList> 
        </ContentTemplate> 
       </asp:UpdatePanel> 
      </td> 
     </tr> 
     <tr> 
      <td class="style49" align="right"> 
       Courses<span class="style23">*</span> : 
      </td> 
      <td class="style50"> 
       <asp:UpdatePanel ID="UpdatePanel2" runat="server"> 
        <ContentTemplate> 
         <asp:DropDownList ID="ddlCourse" runat="server" Width="155px" Class="valid" OnSelectedIndexChanged="ddlCourse_SelectedIndexChanged" 
          AutoPostBack="True" Height="23px"> 
         </asp:DropDownList> 
        </ContentTemplate> 
       </asp:UpdatePanel> 
      </td> 
     </tr> 
     <tr> 
      <td class="style9" align="right"> 
       Faculty<span class="style23">*</span> : 
      </td> 
      <td class="style47"> 
       <asp:UpdatePanel ID="UpdatePanel3" runat="server"> 
        <ContentTemplate> 
         <asp:DropDownList ID="ddlFaculty" runat="server" Width="155px" Class="valid" OnSelectedIndexChanged="ddlFaculty_SelectedIndexChanged" 
          AutoPostBack="True" Height="23px"> 
         </asp:DropDownList> 
        </ContentTemplate> 
       </asp:UpdatePanel> 
      </td> 
     </tr> 
     <tr> 
      <td class="style44" align="right"> 
       Timing<span class="style24">*</span> : 
      </td> 
      <td class="style45"> 
       <asp:UpdatePanel ID="UpdatePanel4" runat="server"> 
        <ContentTemplate> 
         <asp:DropDownList ID="ddlTiming" runat="server" Width="155px" Height="23px" AutoPostBack="True" 
          Class="valid" OnSelectedIndexChanged="ddlTiming_SelectedIndexChanged"> 
         </asp:DropDownList> 
         <asp:Button ID="btnAdd" runat="server" Text="Add" /> 
         <cc1:modalpopupextender id="btnAdd_ModalPopupExtender" runat="server" cancelcontrolid="btnCancleInsertTime" 
          dynamicservicepath="" enabled="True" popupcontrolid="Panel1" targetcontrolid="btnAdd"> 
        </cc1:modalpopupextender> 
        </ContentTemplate> 
       </asp:UpdatePanel> 
      </td> 
     </tr> 
     <tr> 
      <td class="style44" align="right"> 
       Start Date<span class="style23">*</span> : 
      </td> 
      <td class="style45"> 
       <asp:UpdatePanel ID="UpdatePanel6" runat="server"> 
        <ContentTemplate> 
         <asp:TextBox ID="txtInsertdate" runat="server" Width="150px" Height="16px" Class="valid"></asp:TextBox> 
         <cc1:calendarextender id="CalendarExtender1" runat="server" targetcontrolid="txtInsertdate" 
          format="yyyy-MM-dd"> 
        </cc1:calendarextender> 
        </ContentTemplate> 
       </asp:UpdatePanel> 
      </td> 
     </tr> 
     <tr> 
      <td class="style51"> 
       &nbsp; 
      </td> 
      <td class="style45"> 
       &nbsp; 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <div style="text-align: right"> 
        <asp:Button ID="btnSchedule" runat="server" Text="Schedule" Style="font-weight: 700; 
         margin-left: 0px;" Width="81px" Height="24px" OnClick="btnSchedule_Click" /> 
       </div> 
      </td> 
      <td> 
       <asp:UpdatePanel ID="UpdatePanel5" runat="server"> 
        <ContentTemplate> 
         <asp:Button ID="btnreset" runat="server" OnClick="btnreset_Click" Style="font-weight: 700" 
          Text="Reset" Width="67px" CausesValidation="False" UseSubmitBehavior="false" /> 
        </ContentTemplate> 
        <Triggers> 
         <asp:PostBackTrigger ControlID="btnreset" /> 
        </Triggers> 
       </asp:UpdatePanel> 
      </td> 
     </tr> 
     <tr> 
      <td colspan="3"> 
       <asp:Panel ID="Panel1" runat="server" aline="center"> 
        <table style="border: thin solid #FF0000; background: #7F8778"> 
         <tr> 
          <th class="style53"> 
           Please Add a Time 
          </th> 
         </tr> 
         <tr> 
          <td align="center" style="color: #FF0000" class="style53"> 
           <asp:TextBox ID="txtInsertTime" runat="server" Width="124px"></asp:TextBox> 
           &nbsp; EX: 09:15AM 
          </td> 
         </tr> 
         <tr> 
          <asp:UpdatePanel ID="UpdatePanel7" runat="server" UpdateMode="Conditional"> 
           <ContentTemplate> 
            <td align="center" class="style53"> 
             <asp:Button ID="btnInsertTime" runat="server" Text="Add Time" Width="73px" OnClientClick="return InsertTime()" 
              OnClick="btnInsertTime_Click" class="cancel" /> 
             &nbsp; &nbsp; 
             <asp:Button ID="btnCancleInsertTime" Text="Cancel" Width="55px" runat="server" class="cancel" /> 
            </td> 
           </ContentTemplate> 
          </asp:UpdatePanel> 
         </tr> 
        </table> 
       </asp:Panel> 
      </td> 
     </tr> 
    </table> 
    <br /> 
    </form> 
</asp:Content> 
+0

您忘记指定你所点击按钮,它在哪里。你有太多的UpdatePanel。每个人都单独行动。以太网只使用一个UpdatePanel来控制你想要使用它更新的所有控件。 – Aristos 2013-03-19 12:53:14

+0

btnreset和btnInsertTime按钮的点击总是回传。 – user2181075 2013-03-19 12:58:09

+0

如果我使用一个更新面板“btnSchedule”这个按钮点击执行服务器端代码没有验证 – user2181075 2013-03-19 12:59:30

回答

0

你可以尝试像注册与脚本管理器控制:

protected void Page_Load(object sender, EventArgs e) 
{ 
    ScriptManager1.RegisterAsyncPostBackControl(ddlTechnology); 
    ScriptManager1.RegisterAsyncPostBackControl(ddlCourse); 
} 
+0

对于一个更新面板 – user2181075 2013-03-19 13:07:32

+0

在这种情况下,服务器端代码无需验证即可执行 – user2181075 2013-03-19 13:12:10