Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

Masterpage and default.aspx

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jape - 10 Apr 2008 13:09 GMT
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.
Ujval Shah - 10 Apr 2008 14:51 GMT
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");

> 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.
gnewsgroup - 10 Apr 2008 17:53 GMT
On Apr 10, 9:51 am, Ujval Shah <UjvalS...@discussions.microsoft.com>
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.
Jape - 11 Apr 2008 10:12 GMT
Yes, this is what i want.
The gridview is on the contentpage and i want to acess it from the masterpage.

> On Apr 10, 9:51 am, Ujval Shah <UjvalS...@discussions.microsoft.com>
> wrote:
[quoted text clipped - 8 lines]
> would like to get a reference to a control in a child page of the
> master page.
wisccal@googlemail.com - 11 Apr 2008 14:15 GMT
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" %>

<!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>Untitled Page</title>
</head>
<body>
   <form id="form1" runat="server">
   <div>
       <asp:Label ID="myLabel" />
       <asp:ContentPlaceHolder ID="myPlaceHolder" runat="server">
       </asp:ContentPlaceHolder>
   </div>
   </form>
</body>
</html>

Default.aspx:

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

<asp:Content ID="myContent" ContentPlaceHolderID="myPlaceHolder"
Runat="Server">
   <asp:DropDownList ID="myDDL" runat="server">
       <asp:ListItem Value="1" Text="Indeed" />
       <asp:ListItem Value="2" Text="Yeah" />
       <asp:ListItem Value="3" Text="Exactly" />
   </asp:DropDownList>
</asp:Content>

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

> 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
[quoted text clipped - 14 lines]
> > would like to get a reference to a control in a child page of the
> > master page.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.