My Page_Load is hitting twice on any call to the page.
I am using trirand dll to jqgrid. When I refresh the page it is calling the page_load twice. There is no image tag with src blank or noting handler is written.
Please help ASPX Page
<%@ 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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.