[英]Page load twice in asp.net
我的Page_Load在該頁面的任何調用上都擊中兩次。
我正在使用trirand dll到jqgrid。 當我刷新頁面時,它兩次調用page_load。 沒有帶有src空白的圖像標記,或者沒有編寫注釋處理程序。
請幫助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>
服務器端代碼。
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();
}
網格本身會自動返回到托管頁面以加載數據。 本質上,頁面首先被加載(Page_Load執行一次),然后頁面被加載,網格向服務器發出GET請求返回服務器以獲取其數據(因此,第二個請求的PostBack = False)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.