简体   繁体   English

页面在asp.net中加载两次

[英]Page load twice in asp.net

My Page_Load is hitting twice on any call to the page. 我的Page_Load在该页面的任何调用上都击中两次。

I am using trirand dll to jqgrid. 我正在使用trirand dll到jqgrid。 When I refresh the page it is calling the page_load twice. 当我刷新页面时,它两次调用page_load。 There is no image tag with src blank or noting handler is written. 没有带有src空白的图像标记,或者没有编写注释处理程序。

Please help ASPX Page 请帮助ASPX页面

<%@ Page Title="" Language="C#" MasterPageFile="~/app_assets/main.master" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="RM_Admin.rm_app_infrastructure.business_rules._default" %>

<%@ Register Assembly="Trirand.Web" TagPrefix="trirand" Namespace="Trirand.Web.UI.WebControls" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph_main_head_1" runat="server">

<link href="../../app_assets/js/jquery/plugins/colorbox/colorbox.css" rel="stylesheet" type="text/css" />
<script src="../../app_assets/js/jquery/plugins/colorbox/jquery.colorbox.js" type="text/javascript"></script>

<link href="../rm_app.css" rel="stylesheet" type="text/css" />
<script src="../rm_app.js" type="text/javascript"></script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="cph_main_body_1" runat="server">
<form id="Form1" runat="server">
    <div id="page_content" class="page_content">

        <input id="btnCreateRule" type="button" value="Create Business Rule" />
        <asp:DropDownList ID="ddlst_tags" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlst_tags_SelectedIndexChanged"></asp:DropDownList>
        <br />
        <br />

        <trirand:JQGrid runat="server" ID="grdRelease" Width="900px" Height="360" OnSearching="grdRelease_Searching">
            <Columns>
                <trirand:JQGridColumn
                    Searchable="false"
                    TextAlign="Center"
                    Width="40"
                    Sortable="false"
                    CssClass="EditImage" />

                <trirand:JQGridColumn
                    HeaderText="Business Rule"
                    DataField="business_rule_id"
                    DataType="Int"
                    Searchable="true"
                    SearchToolBarOperation="Contains"
                    TextAlign="Center"
                    Width="150" />

                <trirand:JQGridColumn
                    HeaderText="Rule Name"
                    DataField="rule_name"
                    DataType="String"
                    Searchable="true"
                    SearchToolBarOperation="Contains"
                    CssClass="divDescription"
                    Width="300" />


                <trirand:JQGridColumn
                    HeaderText="Rule description"
                    DataField="rule_description"
                    TextAlign="Left"
                    DataType="String"
                    Searchable="true"
                    SearchToolBarOperation="Contains"
                    CssClass="divDescription"
                    Width="400" />

                <trirand:JQGridColumn
                    HeaderText="Created Date"
                    DataField="create_date"
                    Searchable="true"
                    SearchToolBarOperation="Contains"
                    DataType="DateTime"
                    TextAlign="Center" />

            </Columns>
            <ToolBarSettings ShowSearchToolBar="true" />
            <PagerSettings PageSize="50" PageSizeOptions="[50]" />
        </trirand:JQGrid>

        <div id="divShowContent" class="ActionPopupContent" style="display: none;"></div>

    </div>
</form>

Server Side Code. 服务器端代码。

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            bind_tag_dropdown();
            BindBusinessRuleGrid(0);
        }
    }

public void BindBusinessRuleGrid(int n_tag_id)
    {
        obj_dt = obj_document.GetBusinessRules(n_tag_id);

        foreach (DataRow dr in obj_dt.Rows) // search whole table
        {
            dr["rule_description"] = Regex.Replace(dr["rule_description"].ToString(), "<.*?>", string.Empty).Replace("\r\n", string.Empty); //remove all the html tag and new line command
            dr["rule_name"] = Regex.Replace(dr["rule_name"].ToString(), "<.*?>", string.Empty).Replace("\r\n", string.Empty);//remove all the html tag and new line command
        }

        grdRelease.DataSource = obj_dt;
        grdRelease.DataBind();
    }

protected void bind_tag_dropdown()
    {
        ddlst_tags.DataSource = Tools.retrieve_tags();
        ddlst_tags.DataTextField = "tag_title";
        ddlst_tags.DataValueField = "tag_id";
        ddlst_tags.DataBind();
    }

The grid by itself automatically gets back to the page it is hosted on to load the data. 网格本身会自动返回到托管页面以加载数据。 In essence, the page first loads (Page_Load executes once) and then once the page is loaded, the grid does a GET request back to the server to get its data (hence the second request with PostBack = False). 本质上,页面首先被加载(Page_Load执行一次),然后页面被加载,网格向服务器发出GET请求返回服务器以获取其数据(因此,第二个请求的PostBack = False)。

http://www.trirand.net/forum/default.aspx?g=posts&t=900 http://www.trirand.net/forum/default.aspx?g=posts&t=900

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

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