Masterpage and default.aspx

Masterpage and default.aspx

am 10.04.2008 14:09:01 von Jape

Can I refer to the controls on default.aspx from the masterpage?
I have a form on the masterpage which sends information that is in a
gridview in the default.aspx page.

RE: Masterpage and default.aspx

am 10.04.2008 15:51:03 von UjvalShah

Hi,

If you want access control to content page (control, which exists on master
page), then you can access it through like this..

HtmlControl body = (HtmlControl)this.Page.Master.FindControl("Body");

"Jape" wrote:

> Can I refer to the controls on default.aspx from the masterpage?
> I have a form on the masterpage which sends information that is in a
> gridview in the default.aspx page.

Re: Masterpage and default.aspx

am 10.04.2008 18:53:43 von gnewsgroup

On Apr 10, 9:51 am, Ujval Shah
wrote:
> Hi,
>
> If you want access control to content page (control, which exists on master
> page), then you can access it through like this..
>
> HtmlControl body = (HtmlControl)this.Page.Master.FindControl("Body");
>

I think he wants it the other way round. I.e., in his master page, he
would like to get a reference to a control in a child page of the
master page.

Re: Masterpage and default.aspx

am 11.04.2008 11:12:00 von Jape

Yes, this is what i want.
The gridview is on the contentpage and i want to acess it from the masterpage.

"gnewsgroup" wrote:

> On Apr 10, 9:51 am, Ujval Shah
> wrote:
> > Hi,
> >
> > If you want access control to content page (control, which exists on master
> > page), then you can access it through like this..
> >
> > HtmlControl body = (HtmlControl)this.Page.Master.FindControl("Body");
> >
>
> I think he wants it the other way round. I.e., in his master page, he
> would like to get a reference to a control in a child page of the
> master page.
>

Re: Masterpage and default.aspx

am 11.04.2008 15:15:27 von wisccal

Hi Jape,

Given the below markup & code, this may be of help to you:

GridView g = (GridView) myPlaceHolder.FindControl("myDDL");

Site1.master.aspx:

<%@ Master Language="C#" AutoEventWireup="true"
CodeBehind="Site1.master.cs" Inherits="Site1" %>

www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Untitled Page












Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="LoginApp._Default"
MasterPageFile="~/Site1.Master"%>

Runat="Server">








Site1.master.cs:

using System;
using System.Web.UI;
using System.Web.UI.WebControls.

public partial class Site1 : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
GridView g = (GridView) myPlaceHolder.FindControl("myDDL");
}
}

=========
Regards,
Steve
www.stkomp.com

Jape wrote:
> Can I refer to the controls on default.aspx from the masterpage?
> I have a form on the masterpage which sends information that is in a
> gridview in the default.aspx page.
On Apr 11, 11:12 am, Jape wrote:
> Yes, this is what i want.
> The gridview is on the contentpage and i want to acess it from the masterpage.
>
> "gnewsgroup" wrote:
> > On Apr 10, 9:51 am, Ujval Shah
> > wrote:
> > > Hi,
>
> > > If you want access control to content page (control, which exists on master
> > > page), then you can access it through like this..
>
> > > HtmlControl body = (HtmlControl)this.Page.Master.FindControl("Body");
>
> > I think he wants it the other way round. I.e., in his master page, he
> > would like to get a reference to a control in a child page of the
> > master page.