Hi
I have a gird, when click edit link, it will open an winodw. but the page load event run twice.
Please help.
Regards,
Paul.
DefaultT.aspx
-----------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DefaultT.aspx.cs" Inherits="_DefaultT" ValidateRequest="False" EnableEventValidation="false"%>
<%@ Register TagPrefix="sds" Namespace="SessionDS" Assembly="SessionDataSource" %>
<%@ register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;margin:0px">
<head runat="server">
<title></title>
</head>
<body style="margin:0px;height:100%;overflow:hidden;font-family: Tahoma;" scroll="yes" >
<form runat="server" id="mainForm" style="width:100%;height:100%" >
<asp:ScriptManager id="ScriptManager" runat="server" AsyncPostBackTimeOut="600" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function ShowProjectEditForm(id, rowIndex) {
var grid = $find("<%= RadGridProj.ClientID %>");
//alert(id);
var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
grid.get_masterTableView().selectItem(rowControl, true);
//window.radopen("ProjectDetails.aspx?project_id=" + id);
window.radopen("test_page3.aspx");
return false;
}
</script>
</telerik:RadCodeBlock>
<div class="frameTop">
<div class="frameBottom">
<!--<h3 class="currentFolder">Demo Site</h3>-->
<div class="frameInner_xxx">
<telerik:RadSplitter runat="server" width="100%" id="MainSplitter" skin="WebBlue" Height="100%" HeightOffset="65" resizemode="EndPane">
<telerik:RadPane id="LeftPane" runat="server" width="250" MinWidth="100" Height="100%">
</telerik:RadPane>
<telerik:RadSplitBar id="RadSplitBar1" runat="server" collapsemode="Forward"></telerik:RadSplitBar>
<telerik:RadPane id="MiddlePane" runat="server" scrolling="None">
<telerik:RadSplitter id="Content" runat="server" skin="WebBlue" orientation="Horizontal">
<telerik:RadPane id="Radpane3" runat="server" height="400" scrolling="Both" MinWidth="5" MinHeight="5" >
<telerik:RadGrid ID="RadGridProj"
AllowMultiRowSelection="true"
AllowMultiRowEdit="true"
Skin="WebBlue" runat="server"
AllowAutomaticDeletes="True"
AllowAutomaticInserts="True"
Width="97%" PageSize="15"
AllowAutomaticUpdates="True"
AllowPaging="True"
AutoGenerateColumns="False"
ShowStatusBar="false"
EnableAJAX="true"
EnableAJAXLoadingTemplate="true"
AllowFilteringByColumn="true"
LoadingTemplateTransparency="50"
OnItemCreated="RadGridProj_ItemCreated"
OnNeedDataSource="RadGridProj_NeedDataSource"
>
<PagerStyle NextPageText="Next" PrevPageText="Prev" Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="false">
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView CommandItemDisplay="None" DataKeyNames="project_id"
AutoGenerateColumns="False" Width="100%">
<Columns>
<telerik:GridBoundColumn DataField="project_name" HeaderText="Project Name"
SortExpression="project_name" UniqueName="project_name" Visible="true"
AllowFiltering="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Edit_user_name" HeaderText="Edit User" SortExpression="Edit_User_name" UniqueName="Edit_user_name" Visible="false" AllowFiltering="false"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn UniqueName="TemplateEditColumn" AllowFiltering="false">
<ItemTemplate>
<asp:HyperLink ID="EditLink" runat="server" Text="Edit" ForeColor="Gray"></asp:HyperLink>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</telerik:RadPane>
<telerik:RadSplitBar id="RadSplitBar2" runat="server" collapsemode="Both"></telerik:RadSplitBar>
<telerik:RadPane id="ContentPane" runat="server" cssclass="ContentPane" Collapsed="true" >
<asp:Panel id="ContentPanel" Width="95%" Height="95%" runat="server" style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; PADDING-TOP: 4px">
</asp:Panel>
</telerik:RadPane>
</telerik:RadSplitter>
</telerik:RadPane>
</telerik:RadSplitter>
</div>
<!--<p class="itemsCount">xxx items</p>-->
</div>
</div>
<!-- content end -->
<telerik:RadAjaxManager id="RadAjaxManager1" runat="server" onajaxrequest="RadAjaxManager1_AjaxRequest">
<ajaxsettings>
</ajaxsettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel id="LoadingPanel1" Runat="server" Transparency="30" BackColor="#E0E0E0">
<asp:Image style="margin-top:20px" id="Image1" runat="server" AlternateText="Loading..." BorderWidth="0px" ImageUrl="~/img/loading.gif"></asp:Image>
</telerik:RadAjaxLoadingPanel>
<Telerik:RadWindowManager ID="RadWindowManager1"
runat="server" Modal="true"
ReloadOnShow="true"
Skin="Vista" Behaviors="Resize, Pin, Maximize, Move, Reload, Close">
</Telerik:RadWindowManager>
</form>
</body>
</html>
DefaultT.aspx.cs
-----------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Drawing;
using Telerik.Web.UI;
using Telerik.QuickStart;
public partial class _DefaultT : System.Web.UI.Page
{
private string project_id
{
get { return (string)ViewState["project_id"]; }
set { ViewState["project_id"] = value; }
}
protected void Page_Load(object sender, System.EventArgs e)
{
this.project_id = "2CF4CD38-1DE1-4E9A-B0CA-51A25A1EE0F5";
this.RadGridProj.Rebind();
}
protected void RadGridProj_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
Project proj = new Project();
DataTable dt = proj.GetProjectDetailByID(new Guid(this.project_id));
RadGridProj.DataSource = dt;
}
protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
{
if (e.Argument == "Rebind")
{
RadGridProj.MasterTableView.SortExpressions.Clear();
RadGridProj.MasterTableView.GroupByExpressions.Clear();
RadGridProj.DataSource = null;
RadGridProj.Rebind();
}
}
protected void RadGridProj_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
HyperLink editLink = e.Item.FindControl("EditLink") as HyperLink;
editLink.Attributes["href"] = "#";
editLink.Attributes["onclick"] = string.Format("return ShowProjectEditForm('{0}','{1}');",
e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["project_id"], e.Item.ItemIndex);
}
}
}
test_page3.aspx
----------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test_page3.aspx.cs" Inherits="test_page3" %>
<%@ register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager" runat="server" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
</script>
</telerik:RadCodeBlock>
<div>
<asp:Label ID="id1" runat="server" Text="Page Load Count:"></asp:Label>
<asp:TextBox ID="txt_page_load" runat="server"></asp:TextBox>
</div>
<Telerik:RadWindowManager ID="RadWindowManager1"
runat="server" Modal="true"
ReloadOnShow="true"
Skin="Vista" Behaviors="Resize, Pin, Maximize, Move, Reload, Close">
<Windows>
</Windows>
</Telerik:RadWindowManager>
</form>
</body>
</html>
test_page3.aspx.cs
-----------------------------
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class test_page3 : System.Web.UI.Page
{
protected Guid property_id;
int page_load_count = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["PageLoadCount"] == null)
{
page_load_count = 1;
this.txt_page_load.Text = page_load_count.ToString();
Session["PageLoadCount"] = page_load_count;
}
else
{
page_load_count = int.Parse(Session["PageLoadCount"].ToString());
page_load_count = page_load_count + 1;
Session["PageLoadCount"] = page_load_count;
}
this.txt_page_load.Text = page_load_count.ToString();
}
protected void x_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(Page.GetType(), "newkey", "ShowInsertProjectForm();", true);
}
}