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

相關問題