473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2202
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)th is.Page.Master. FindControl("Bo dy");

"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...@disc ussions.microso ft.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)th is.Page.Master. FindControl("Bo dy");
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...@disc ussions.microso ft.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)th is.Page.Master. FindControl("Bo dy");

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.F indControl("myD DL");

Site1.master.as px:

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="myLabel" />
<asp:ContentPla ceHolder ID="myPlaceHold er" runat="server">
</asp:ContentPlac eHolder>
</div>
</form>
</body>
</html>

Default.aspx:

<%@ Page Language="C#" AutoEventWireup ="true"
CodeBehind="Def ault.aspx.cs" Inherits="Login App._Default"
MasterPageFile= "~/Site1.Master"%>

<asp:Content ID="myContent" ContentPlaceHol derID="myPlaceH older"
Runat="Server">
<asp:DropDownLi st ID="myDDL" runat="server">
<asp:ListItem Value="1" Text="Indeed" />
<asp:ListItem Value="2" Text="Yeah" />
<asp:ListItem Value="3" Text="Exactly" />
</asp:DropDownLis t>
</asp:Content>
Site1.master.cs :

using System;
using System.Web.UI;
using System.Web.UI.W ebControls.

public partial class Site1 : System.Web.UI.M asterPage
{
protected void Page_Load(objec t sender, EventArgs e)
{
GridView g = (GridView) myPlaceHolder.F indControl("myD DL");
}
}

=========
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...@discussio ns.microsoft.co mwrote:
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...@disc ussions.microso ft.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)th is.Page.Master. FindControl("Bo dy");
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
1088
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 added a members-only section where I want to use a second masterpage, and am now having trouble. My member-startpage contains: A WebPartManager and 1 WebPartzone, with 3 gridviews each connected to a
4
2359
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 this: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ie:MasterPageFile="~/MasterPage_IE.master"
6
2702
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 MasterPage is used by pages not only in root but in other subfolders. I have this in My MasterPage
6
6175
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 Creating Control - Content. Content controsl can only be used in a content page." I know that there's an issue w/ nested masters, but I'm only trying to use one. Interestingly, if I run the site, it builds and displays properly despite this error. Any...
7
13046
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 changed from default.aspx to students.aspx. I tried to create a subroutine in MasterPage.master.vb to do it. The code is as following. But, the default.aspx's content is shown in MasterPage even I clicked the student button.
8
2094
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
1250
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 way of doing this! Anybody know?
8
11777
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: MasterPage.aspx ScriptManager1 UpdatePanel1
1
1805
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 hrefs etc.. the usual stuff.. I also have a sub section on the site.. where aspx files arent in the root.. ie: /rootfiles.aspx here.. then /subsection/subfiles.aspx The menu is fine and dandy with the usual relative references like <a
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.