Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 28th, 2007, 06:03 AM
Authorized User
 
Join Date: May 2007
Location: Frankfurt, Germany, Germany.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to DarkForce
Default Accessing through pages

Hi.
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
__________________
Ivan
  #2 (permalink)  
Old May 29th, 2007, 07:30 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: , , USA.
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Example:

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

Sorry,

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.

case2:
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
  #4 (permalink)  
Old May 30th, 2007, 04:31 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:07 PM.


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