2013-10-03 53 views
0

在我的项目中有一些页面继承相同的主页面,除1或2页面外,所有页面都响应,代码没有任何变化。 我在按钮上插入断点点击按钮没有效果。 我该如何检查问题。 请帮助页面不刷新按钮点击

这里是我的网页的代码

<%@ Page Title="Product Stock" Language="C#" MasterPageFile="~/admin/AdminMaster.master" AutoEventWireup="true" CodeFile="ProductStock.aspx.cs" Inherits="admin_ProductStock" %> 

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> 
    <style type="text/css"> 
     .auto-style3 { 
      width: 259px; 
     } 
     .auto-style4 { 
      width: 479px; 
     } 
     .auto-style5 { 
      height: 65px; 
     } 
     .auto-style6 { 
      width: 479px; 
      height: 65px; 
     } 
     .auto-style7 { 
      height: 74px; 
     } 
     .auto-style8 { 
      width: 479px; 
      height: 74px; 
     } 
     .auto-style9 { 
      width: 69px; 
     } 
     .auto-style10 { 
      height: 74px; 
      width: 68px; 
     } 
     .auto-style11 { 
      height: 65px; 
      width: 68px; 
     } 
     .auto-style12 { 
      width: 68px; 
     } 
     .auto-style13 { 
      width: 451px; 
     } 
     .auto-style14 { 
      width: 451px; 
      height: 74px; 
     } 
     .auto-style15 { 
      width: 451px; 
      height: 65px; 
     } 
    </style> 
</asp:Content> 
<asp:Content ID="Content2" runat="server" contentplaceholderid="ContentPlaceHolder1"> 
    <table style="width:100%;"> 
     <tr> 
      <td> 
       <asp:Image ID="Image1" runat="server" Height="123px" ImageUrl="~/admin/images/insert.jpg" Width="158px" /> 
      </td> 
      <td class="auto-style4"> 
       <asp:Label ID="lblinsertion" runat="server" BackColor="#FFFF66" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="Insert Product Stock Information"></asp:Label> 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      </td> 
      <td class="auto-style12">&nbsp;</td> 
     </tr> 
     <tr> 
      <td class="auto-style5"> 
       <asp:Label ID="lblproductname" runat="server" Text="Product Name" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td class="auto-style6"> 
       <asp:DropDownList ID="ddlprdctname" runat="server" Width="235px" ValidationGroup="vg1"></asp:DropDownList> 
      </td> 
      <td class="auto-style11"> 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="ddlprdctname" ErrorMessage="Select Product Name" ValidationGroup="vg1"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td> 
       <asp:Label ID="lblquantity" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td class="auto-style4"> 
       <asp:TextBox ID="txtquantity" runat="server" Width="235px" ValidationGroup="vg1"></asp:TextBox> 
      </td> 
      <td class="auto-style12"> 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtquantity" ErrorMessage="Enter Quantity" ValidationGroup="vg1"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td> 
       <asp:Label ID="lblstocktype" runat="server" Text="Stock Type" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td class="auto-style4"> 
       <asp:DropDownList ID="ddlstocktype" runat="server" Width="235px" Height="42px" ValidationGroup="vg1"></asp:DropDownList> 
      </td> 
      <td class="auto-style12"> 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="ddlstocktype" ErrorMessage="Please Enter Stock Type" ValidationGroup="vg1"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td> 
       <asp:Label ID="lblstockdate" runat="server" Text="Stock Date" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td class="auto-style4"> 
       <asp:TextBox ID="txtstockdate" runat="server" ValidationGroup="vg1" Height="55px" Width="235px"></asp:TextBox> 
      </td> 
      <td class="auto-style12"> 
       <asp:Label ID="lbldateformat" runat="server" Text="dd/mm/yy"></asp:Label> 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtstockdate" ErrorMessage="Please Enter Stock Date" ValidationGroup="vg1"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td class="auto-style3"></td> 
      <td class="auto-style4"> 
       <asp:Button ID="btnInsert" runat="server" Text="Insert" Width="125px" ValidationGroup="vg1" OnClick="btnInsert_Click" />    
      </td> 
      <td> 
       <asp:Button ID="check" runat="server" Text="Lets Check" /> 
      </td> 
      <td class="auto-style12">&nbsp;</td> 
     </tr> 
     <tr> 
      <td colspan="3"> 
       <asp:Label ID="lblmsg" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
     </tr> 
    </table> 
</asp:Content> 

<asp:Content ID="Content3" runat="server" contentplaceholderid="ContentPlaceHolder2"> 
    <asp:Panel ID="ViewPanel" runat="server"> 
     <table style="width:100%;"> 
      <tr> 
       <td class="auto-style3"> 
        <asp:Image ID="Image2" runat="server" Height="100px" ImageUrl="~/admin/images/view.jpg" Width="133px" /> 
       </td> 
       <td> 
        <asp:Label ID="Label1" runat="server" BackColor="Yellow" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="View All Information"></asp:Label> 
       </td> 
       <td>&nbsp;</td> 
      </tr> 
     </table> 
    <asp:GridView ID="gridview" AutoGenerateColumns="false" runat="server" style="margin-left: 0px" AllowPaging="True" AllowSorting="True" CellPadding="3" Height="238px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="Solid" BorderWidth="1px" CellSpacing="2" OnRowCommand="gridview_RowCommand" OnPageIndexChanging="gridview_PageIndexChanging"> 
     <Columns> 
      <asp:BoundField HeaderText="Stock ID" DataField="StockID" /> 
      <asp:BoundField HeaderText="Product Name" DataField="ProductID" /> 
      <asp:BoundField HeaderText="Quantity" DataField="Quantity" /> 
      <asp:BoundField HeaderText="Stock Type" DataField="StockType" /> 
      <asp:BoundField HeaderText="Stock Date" DataField="StockDate" /> 

      <asp:TemplateField HeaderText="Delete Record"> 
       <ItemTemplate> 
        <asp:Button ID="delete" OnClientClick="return confirm('Are You Sure To Delete The Record?')" Text="Delete This Record" CommandName="del" CommandArgument='<%# Eval("StockID") %>' runat="server" /> 
       </ItemTemplate> 
      </asp:TemplateField> 
      <asp:TemplateField HeaderText="Edit Record"> 
       <ItemTemplate> 
        <asp:Button ID="update" CommandName="upd" Text="Edit this Record" CommandArgument='<%# Eval("StockID") %>' runat="server" /> 
       </ItemTemplate> 
      </asp:TemplateField> 
     </Columns> 
     <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /> 
     <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /> 
     <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /> 
     <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /> 
     <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /> 
     <SortedAscendingCellStyle BackColor="#FFF1D4" /> 
     <SortedAscendingHeaderStyle BackColor="#B95C30" /> 
     <SortedDescendingCellStyle BackColor="#F1E5CE" /> 
     <SortedDescendingHeaderStyle BackColor="#93451F" /> 
     </asp:GridView> 

    <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label> 
     </asp:Panel> 
    <br /> 

</asp:Content> 

<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server"> 
<asp:Label ID="lblupdate" runat="server" Text="Select the record to be updated" Font-Names="Segoe Print" Font-Size=20></asp:Label> 

    <asp:Panel ID="UpdatePanel" runat="server"> 

<table style="width:100%;"> 
     <tr> 
      <td> 
       <asp:Image ID="Image3" runat="server" Height="123px" ImageUrl="~/admin/images/insert.jpg" Width="158px" /> 
      </td> 
      <td > 
       <asp:Label ID="lblupdupdation" runat="server" BackColor="#FFFF66" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="Update Product Stock Information"></asp:Label> 
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      </td> 
      <td >&nbsp;</td> 
     </tr> 
    <tr> 
      <td> 
       <asp:Label ID="lblupdstockid" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td> 
       <asp:TextBox ID="txtupdstockid" runat="server" ReadOnly="true" Width="235px"></asp:TextBox> 
      </td> 
      </tr> 
     <tr> 
      <td > 
       <asp:Label ID="lblupdproductname" runat="server" Text="Product Name" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td > 
       <asp:DropDownList ID="ddlupdprdctname" runat="server" Width="235px"></asp:DropDownList> 
      </td> 
      <td > 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlupdprdctname" ErrorMessage="Enter Product Name"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td> 
       <asp:Label ID="lblupdquantity" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td> 
       <asp:TextBox ID="txtupdquantity" runat="server" Width="235px"></asp:TextBox> 
      </td> 
      <td > 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtupdquantity" ErrorMessage="Enter Quantity"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td> 
       <asp:Label ID="lblupdstocktype" runat="server" Text="Stock Type" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td > 
       <asp:DropDownList ID="ddlupdstocktype" runat="server" Width="235px"></asp:DropDownList> 
      </td> 
      <td> 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ddlupdstocktype" ErrorMessage="Please Enter Stock Type"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td> 
       <asp:Label ID="lblupdstockdate" runat="server" Text="Stock Date" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
      <td> 
       <asp:TextBox ID="txtupdstockdate" runat="server" ValidationGroup="vg1" Height="16px" Width="235px"></asp:TextBox> 
      </td> 
      <td > 
       <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtupdstockdate" ErrorMessage="Please Enter Stock Date" ValidationGroup="vg1"></asp:RequiredFieldValidator> 
      </td> 
     </tr> 

     <tr> 
      <td></td> 
      <td > 
       <asp:Button ID="btnUpdate" runat="server" Text="Update" Width="125px" ValidationGroup="vg1" OnClick="btnUpdate_Click" /> 
      </td> 
      <td >&nbsp;</td> 
     </tr> 
     <tr> 
      <td colspan="3"> 
       <asp:Label ID="lblupdmsg" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label> 
      </td> 
     </tr> 
    </table> 

    </asp:Panel> 
</asp:Content> 

我的客户端代码按钮

protected void btnInsert_Click(object sender, EventArgs e) 
    { 
     try 
     { 
     int productID, quantity; 
     string stockType; 
     DateTime stockDate; 

     productID = int.Parse(ddlprdctname.SelectedValue); 
     quantity = int.Parse(txtquantity.Text.Trim()); 
     stockType = ddlstocktype.SelectedValue.ToString().Trim(); 
     stockDate = DateTime.Parse(txtstockdate.Text.Trim()); 
     ProductStock prdctstock = new ProductStock(); 
     prdctstock.ProductID = productID; 
     prdctstock.Quantity = quantity; 
     prdctstock.StockType = stockType; 
     prdctstock.StockDate = stockDate; 
     if (new InsertAction().InsertData(prdctstock)) 
       { 
        lblmsg.Text = "Inserted Sucessfully"; 
        ViewPanel.Visible = true; 
       } 
       else 
       { 
        lblmsg.Text = "Please Check all the fields"; 
       } 

      BindGridView(); 
      ProductInfo prdctinfo = new ProductInfo(); 
      if (stockType == "In") 
      { 
       prdctinfo.Quantity += quantity; 
      } 
      if (stockType == "Out") 
      { 
       prdctinfo.Quantity -= quantity; 
      } 
      } 

      catch (Exception ex) 
     { 
      if (ex is FormatException) 
      { 
       lblmsg.Text = "Character value are not allowed"; 
      } 
      else 
      { 
       lblmsg.Text = ex.Message; 

      } 
     } 


    } 
+1

您需要展示一些代码,然后才能提供帮助。如果一切正常,你不会在这里:) – CodingIntrigue

+0

你可以把你的一些代码放在这里吗? – Neel

+0

如果您向我们显示您的代码,我们可以帮助您。 –

回答

0

把断点的地方在那里它击中。查看调用堆栈,并找到为什么它不会触发您想要触发的方法时跳到这一点。如果没有更多的信息,就不能做太多事情。 希望这有助于

+2

这应该是一个评论,因为它没有回答为什么页面不按钮点击刷新的问题。有没有办法知道为什么在一分钟,但这只是意味着没有人可以真正回答这个问题 – CodingIntrigue

0

我看到一些不需要的代码的

1),请取下ValidationGroup="vg1"在你所有的asp.net控件按钮除外。

2)不要用面板,一段时间后点击按钮不起作用使用面板控制,所以请使用表而不是面板(或删除ASP:面板控制)

3),必须检查按钮点击事件与服务器端相同。

4)如果你给我我们的服务器端代码,那么我会回应你!

+0

先生所有其他网页也是相同的,我用面板和validationgroup =“vg1”,但他们正在工作 – VJain

+0

先生我已经删除所有vg1但仍然是相同的条件 – VJain

+0

先生所有的4点改变,但没有修改 – VJain