2013-10-10 177 views
0

这是我的第一篇文章,所以请温和。关于下面的标记和代码(这全部在用户控件中),这可以很好地开始。当我尝试从窗体视图呈现的列表中删除多个项目时,会发生此问题。浏览器不刷新

我可以删除一个项目,页面重新加载,我删除的项目不见了。如果我然后点击另一个项目上的删除,则根本没有明显的回应。在后面的页面中放置所有函数等的断点表明它确实经历了它应该做的所有事情,但是浏览器根本没有显示任何响应。如果我然后手动刷新浏览器,我删除的第二个项目已经消失。

我真的需要让浏览器刷新每次我点击删除,如果可能的话,我可以做的理解问题,请。我已经尝试使用ViewStateMode =“禁用/启用”在formview和中继器分开和一起。

其他 - 我也试过禁用缓存。

在此先感谢。

<asp:FormView ID="fvDrugActiveSubstance" runat="server" DefaultMode="ReadOnly" UseSubmitBehavior="false" Width="100%"> 
    <ItemTemplate> 
     <table style="border-collapse: collapse; border-spacing: 0;width: 100%;"> 
      <tr> 
       <th style="width:80%;">Name</th> 
       <th style="width:10%;">Edit</th> 
       <th style="width:10%;">Delete</th> 
      </tr> 
      <asp:Repeater ID="rptrDrugActiveSubstance" runat="server" OnItemCommand="rptrDrugActiveSubstance_ItemCommand"> 
       <ItemTemplate> 
        <tr class="view_table" style=""> 
         <td> 
          <asp:Label Text='<%# Eval("ActiveSubstanceName") %>' ID="lblName" runat="server" /> 
          <asp:Label Text='<%# Eval("DrugSafetyDrugCode") %>' ID="lblCode" runat="server" Visible="false" /> 
         </td> 
         <td> 
          <img onclick='<%# String.Format("openDrugActiveSubstanceWindow({1},{0},\"Write\");return false;",((DrugActiveSubstance)Container.DataItem).DrugSafetyDrugCode.ToString(),((DrugActiveSubstance)Container.DataItem).DrugSafetyDrugActiveSubstanceCode) %>' src="/images/grid_icons/edit.png" style="cursor: pointer;" title="Edit" /> 
         </td> 
         <td> 
          <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("DrugSafetyDrugActiveSubstanceCode") %>' style="cursor: pointer;" CommandName="cmd_delete" ImageUrl="~/images/grid_icons/Delete.gif" ToolTip="Delete" /> 
         </td> 
        </tr> 
       </ItemTemplate> 
       <AlternatingItemTemplate> 
        <tr class="view_table_alt"> 
         <td> 
          <asp:Label Text='<%# Eval("ActiveSubstanceName") %>' ID="lblName" runat="server" /> 
          <asp:Label Text='<%# Eval("DrugSafetyDrugCode") %>' ID="lblCode" runat="server" Visible="false" /> 
         </td> 
         <td> 
          <img onclick='<%# String.Format("openDrugActiveSubstanceWindow({1},{0},\"Write\");return false;",((DrugActiveSubstance)Container.DataItem).DrugSafetyDrugCode.ToString(),((DrugActiveSubstance)Container.DataItem).DrugSafetyDrugActiveSubstanceCode) %>' src="/images/grid_icons/edit.png" style="cursor: pointer;" title="Edit" /> 
         </td> 
         <td id="tdDelete"> 
          <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("DrugSafetyDrugActiveSubstanceCode") %>' style="cursor: pointer;" CommandName="cmd_delete" ImageUrl="~/images/grid_icons/Delete.gif" ToolTip="Delete" /> 
         </td> 
        </tr> 
       </AlternatingItemTemplate> 
      </asp:Repeater> 
     </table> 
    </ItemTemplate> 
</asp:FormView> 



protected void rptrDrugActiveSubstance_ItemCommand(object source, RepeaterCommandEventArgs e) 
{ 
    drugSafetyService.DeleteDrugActiveSubstance(int.Parse(e.CommandArgument.ToString())); 
    Response.Redirect(HttpContext.Current.Request.Url.ToString().Split('?')[0] + "?#drugAS_accordian"); 
} 
+0

在Chrome上打开开发者工具,并检查服务器的响应情况。检查您的HTTP响应是否有任何变化。 – rpf

+0

谢谢你。我试过了,第一次点击(成功的)的结果为200和304,然后(中止)第二次点击的结果。除了显而易见的情况外,我不知道这意味着什么。我不明白是什么流产或为什么。 – user1770738

+0

304代表“未修改”(http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html),仅用于GET http响应。这意味着您正在执行GET,而不是POST。请在第一次点击后检查btnDelete按钮的onclick属性是什么 – rpf

回答

0

我打算把这个粉笔写成经验。找到一个导致中止问题的javascript函数现在已解决。