简体   繁体   English

单击按钮时页面未刷新

[英]Page is not refreshing on button click

In my project there are number of page inheriting the same masterpage and all are responding except 1 or 2 page, there is no change in code every thing is right. 在我的项目中,有许多页面继承同一个母版页面,并且除1或2页外,所有页面都在响应,代码没有任何变化,这都是对的。 I inserted breakpoint on button click button no effect. 我在按钮单击按钮上插入断点没有效果。 How can i check the Problem. 我如何检查问题。 Please help 请帮忙

Here is the code of my page 这是我页面的代码

<%@ 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>

My Client side code for button 我的按钮的客户端代码

 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;

            }
        }


    }

Put the breakpoint somewhere where it hits. 将断点放在命中的位置。 Look at the call stack and step over to the point when you find why it is not going to the method you want to trigger. 查看调用堆栈,并逐步查找到为什么它不会转到您要触发的方法。 Can't do much without more information. 没有更多信息就做不了多少。 Hope this helps 希望这可以帮助

I saw few unwanted code's 我看到了一些不需要的代码

1) please remove the ValidationGroup="vg1" in your all asp.net controls except button . 1)请在除按钮之外的所有asp.net控件中删除ValidationGroup="vg1"

2) Don't use panel , some time the button click not working on using panel control, so please use table instead of panel .(or remove the asp:panel control ) 2)不要使用面板,有时使用面板控件无法单击按钮,因此请使用表格代替面板。(或删除asp:panel控件)

3) and must check the button click event same as server side . 3)并且必须检查与服务器端相同的按钮单击事件。

4) If you give me our server side code then i will response you !! 4)如果您给我我们的服务器端代码,那么我会回复您!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM