473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Masterpage and default.aspx

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.
Apr 10 '08 #1
4 2177
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.
Apr 10 '08 #2
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.
Apr 10 '08 #3
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 <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.
Apr 11 '08 #4
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

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 <J...@discussions.microsoft.comwrote:
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 <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.
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Herman verschooten | last post by:
Hi, I am creating my first real ASP.NET 2.0 site and want to use the some of the new features. I created a masterpage with my main layout and added several contentpages, no problem so far. I...
4
by: Alexander Widera | last post by:
Hi, it is possible to set the browser dependent masterpage in the web.config, and how? in the page attributes it is an easy way, but in the web.config? In the page-tag it would look like...
6
by: Mirek Endys | last post by:
HEEELP!!!! I have a big problem :))))) How to use url in CSS stylesheet file that is linked into MasterPage. The tilda '~' (as shortcut to the root of the webserver) is not working, and my...
6
by: =?Utf-8?B?QmVuIFIu?= | last post by:
Hi, WHen I specify my master page in the page's @Page directive, no problems. However, when I put it ias an attribute in Web.config's page element, the designer fails. It just says "Error...
7
by: Bon | last post by:
Dear all I create a master page with image buttons on the left-hand side for navigation. When a user clicks the student button, the content (i.e. ContentPlaceholder) in masterpage will be...
8
by: Randy Smith | last post by:
Hi, I now need to add MasterPages to a number of existing forms, but when I add the code for MasterPage, the MasterPage does NOT appear when it runs. Any thoughts? TIA, Randy Smith
2
by: Steve Kershaw | last post by:
Hi, I have an ASP.NET application with a MasterPage that has a method defined as public. Now I want to run this MasterPage method from INSIDE the default.aspx page. I know there has to be a...
8
by: BiffMaGriff | last post by:
Hello, I am using VS2005 to code webapps using C#. I am trying to call the javascript function alert() from my codebehind. I am using master pages and AJAX. My page structure is as follows: ...
1
by: =?Utf-8?B?bWFya203NQ==?= | last post by:
There is probably some simple answer to my question, but i'm still new to this a bit.. I have a master page.. with a menu system which is coded onto the masterpage.aspx... it uses A tags with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.