Wrox Programmer Forums
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 28th, 2007, 06:03 AM
Authorized User
Join Date: May 2007
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to DarkForce
Default Accessing through pages

I am trying to access the sqldatascource in the masterpage.
I try to do so by tipping in into a textbox on a contentpage.
i want the textbox text to change the sqldatascource selectcommand.
how can i access these objects through pages?

best regards

So long
Old May 29th, 2007, 07:30 AM
Friend of Wrox
Join Date: Feb 2006
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts

What do you mean by "tipping in"?

In general you can access any control on the MasterPage from a Page by using the Page class' Master property and casting to the type of control you are accessing.


CType(Page.Master.FindControl("txtBxWhatever"), TextBox).Text
Old May 30th, 2007, 01:10 AM
Authorized User
Join Date: May 2007
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to DarkForce


I haven't been to the U.S.A for almost a year now, i meant typing in, not tipping in.
I tryed your example, but i came to no conclusion. i have a Button named Button1 in the Masterpage.
And i have a textbox named textbox1 in the contentpage. I want to program an event that works as following:
By changeing the content in the textbox in the content page, i want to change the button name in the masterpage.

i am asking for this example because, i am trying to access a sqldatascource on a masterpage by event and change the selectcommand of this sqldatascource and the controltype by event.

best regards
Old May 30th, 2007, 04:31 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

Here's what you can do:

1. In the MasterPage, create a property called SelectCommand of type String.

2. In the Setter and Getter of this property get the command text from the underlying SqlCommand SqlDataSource control.

3. On your content page, add a MasterType directive like this:

<%@ MasterType VirtualPath="~/MasterPage.master" %>

Just add this to the top of the page, right below the Page directive and make sure it points to the correct master page.

4. The Code Behind has now strongly typed access to the master, so you can do something like this:

this.Master.SelectCommand = "Bla Bla Bla";

Hope this helps,


Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem accessing Request.Form with Master Pages kittu_asa ASP.NET 2.0 Basics 1 February 28th, 2008 09:38 AM
Problem accessing Request.Form with Master Pages niceFEPF ASP.NET 2.0 Basics 7 February 14th, 2008 04:25 PM
Master Pages, Content Pages and CSS carliviris Visual Studio 2005 0 January 8th, 2008 05:56 PM
accessing pages with roles authorization saif44 ASP.NET 2.0 Professional 9 March 22nd, 2006 03:08 PM
Web pages constructing: I-mode(mobile) pages karib Dreamweaver (all versions) 3 June 6th, 2004 09:48 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.