Search this blog

Tuesday, June 9, 2009

Call Parent Page Method from Child Page thru ASP.NET, C#

The following codesnippet helps to call parent Page Javascript method from Child Page’s Code behind.

As per this code, I have a method "ParentMethod1()" in Parent page.

using System.Text;

StringBuilder sbScript = new StringBuilder();

sbScript.Append("<script language='javascript'>");

sbScript.Append(Environment.NewLine);

sbScript.Append("window.parent.ParentMethod1())");

sbScript.Append(Environment.NewLine);

sbScript.Append("</script>");

ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", sbScript.ToString());

No comments:

Post a Comment