2011-06-21 508 views
0

我有一個更新面板,裏面有gridview。我還有一個更新面板中的按鈕,在點擊事件中觸發它。在gridview模板字段中,我有一個linkbutton,它應該在點擊時重置用戶密碼。當我點擊重置按鈕時,它什麼都不做。asp.net更新面板

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
<ContentTemplate> 
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" Height="240px" Width="952px" Visible = "False" EnableModelValidation="True" EnableViewState="false">  
<Columns> 
<asp:BoundField DataField="personid" HeaderText="Person ID" /> 
<asp:BoundField DataField="firstname" HeaderText="Account No" /> 
<asp:BoundField DataField="surname" HeaderText="Skin Centre" /> 
<asp:BoundField DataField="email" HeaderText="Email" /> 
<asp:BoundField DataField="password" HeaderText="Password" ControlStyle-Width="200px"> 
<ControlStyle Width="200px"></ControlStyle> 
</asp:BoundField><asp:TemplateField HeaderText=""> 
<ItemTemplate> 
<asp:LinkButton ID="lnkBtn" runat="server" OnCommand="lnkBtn_Command" CommandArgument='<%# Eval("CmdArgument") %>' Text='<%# Eval("CmdArgument", "&nbsp;&nbsp;&nbsp;reset&nbsp;&nbsp;&nbsp;") %>' /> 
</ItemTemplate> 
</asp:TemplateField> 
</Columns> 
</asp:GridView> 

<asp:UpdateProgress ID="UPCalendarUpdateProgress" runat="server" DisplayAfter="0"> 
<ProgressTemplate> 
<div style="width:100%; height: 100%; border: 0px solid; position: absolute; top: 0; left: 0; text-align: center;"> 
<div id="loadingMessage"> 
<asp:Label ID="LbLoadingMessage" runat="server" ForeColor = "Red" Font-Size="XX-Large" Text="Loading the account details..." CssClass="loading-message-text">    
</asp:Label><br /> 
<img src="images/loadingAnimation.gif" alt="" style="margin-top: 20px;" /></div>  
</div> 
</ProgressTemplate> 
</asp:UpdateProgress> 
<div style="margin-top:50px;"> 
<asp:button ID="rstButton" runat="server" text="Complete Reset" OnClick ="rstButton_Click" Visible ="false"/> 
</div> 
</ContentTemplate> 
<Triggers> 
<asp:AsyncPostBackTrigger ControlID="rstButton" EventName="Click" /> 
</Triggers> 
</asp:UpdatePanel> 

任何想法將不勝感激。

+0

做了這項工作,如果你刪除更新面板? – Aristos

+0

@aristos這是一個很好的問題。是的,以前它是沒有更新面板的工作。因爲我必須更新一些20000條記錄,我只是把它們放在更新面板中,至少用戶知道發生了什麼 – sam

+0

然後使用控制檯現在檢查javacript錯誤 – Aristos

回答

0

更新您的事件名稱從點擊到確切的按鈕事件名稱,

<Triggers> 
    <asp:AsyncPostBackTrigger ControlID="rstButton" EventName="rstButton_Click" /> 
</Triggers> 

希望這有助於..

+0

在UpdatePanel'UpdatePanel1'的觸發器的關聯控件'gv'上找不到名爲'rstButton_Click'的事件。 – sam

+0

爲什麼你的按鈕可見性設置爲false?請刪除可見性屬性並再次嘗試。 – Harun

0

請再試一次這樣

<asp:ScriptManager ID="scm" runat="server" /> 
     <asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
      <ContentTemplate> 
       <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" Height="240px" Width="952px" 
        Visible="False" EnableModelValidation="True" EnableViewState="false"> 
        <Columns> 
         <asp:BoundField DataField="personid" HeaderText="Person ID" /> 
         <asp:BoundField DataField="firstname" HeaderText="Account No" /> 
         <asp:BoundField DataField="surname" HeaderText="Skin Centre" /> 
         <asp:BoundField DataField="email" HeaderText="Email" /> 
         <asp:BoundField DataField="password" HeaderText="Password" ControlStyle-Width="200px"> 
          <ControlStyle Width="200px"></ControlStyle> 
         </asp:BoundField> 
         <asp:TemplateField HeaderText=""> 
          <ItemTemplate> 
           <asp:LinkButton ID="lnkBtn" runat="server" OnCommand="lnkBtn_Command" CommandArgument='<%# Eval("CmdArgument") %>' 
            Text='<%# Eval("CmdArgument", "&nbsp;&nbsp;&nbsp;reset&nbsp;&nbsp;&nbsp;") %>' /> 
          </ItemTemplate> 
         </asp:TemplateField> 
        </Columns> 
       </asp:GridView> 
       <div style="margin-top: 50px;"> 
        <asp:Button ID="rstButton" runat="server" Text="Complete Reset" OnClick="rstButton_Click" 
         Visible="true" /> 
       </div> 
      </ContentTemplate> 
      <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="rstButton" /> 
       <asp:AsyncPostBackTrigger ControlID="gv" /> 
      </Triggers> 
     </asp:UpdatePanel> 
     <asp:UpdateProgress ID="UPCalendarUpdateProgress" runat="server" DisplayAfter="0"> 
      <ProgressTemplate> 
       <div style="width: 100%; height: 100%; border: 0px solid; position: absolute; top: 0; 
        left: 0; text-align: center;"> 
        <div id="loadingMessage"> 
         <asp:Label ID="LbLoadingMessage" runat="server" ForeColor="Red" Font-Size="XX-Large" 
          Text="Loading the account details..." CssClass="loading-message-text">    
         </asp:Label><br /> 
         <img src="images/loadingAnimation.gif" alt="" style="margin-top: 20px;" /></div> 
       </div> 
      </ProgressTemplate> 
     </asp:UpdateProgress> 

我希望這將解決您的問題....

+0

它仍然是相同的 – sam

+0

@sam現在檢查它... –

+0

它沒有任何區別 – sam