2013-10-03 420 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