CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 11/29/2007 9:11:14 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 14 Views: 18 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
15 Items, 1 Pages 1 |< << Go >> >|
Gustavo Villa
Asp.Net User
Controls in a Child Page11/29/2007 9:11:14 AM

0/0

Hello,

I need to access the controls of a child page to set the properties of some of them. When I use Me.Form.Controls in the child .vb page I get the controls of the master page. I tried with the content control and some other possibilities without success. Any suggestion?

 Thank you,

Gustavo
 


scott@elbandit.
Asp.Net User
Re: Controls in a Child Page11/29/2007 10:19:51 AM

0/0

Master page HTML:

<html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
       <title>Untitled Page</title>
</
head>
<
body>
       
<form id="form1" runat="server">
            
<div>
                
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server"></asp:contentplaceholder>
            
</div>
       
</form>
</body>
</
html>

Master page Code behind:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
          
CType(Me.ContentPlaceHolder1.FindControl("label1"), Label).Text = "hello"
End Sub

Page that uses the master page:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</
asp:Content>

This shows that you can access controls on the child page from the master page. Does this solve your problem?


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

Scott ASP.net blog

Gustavo Villa
Asp.Net User
Re: Controls in a Child Page11/29/2007 12:09:06 PM

0/0

 Thank you, Scott, but It does not solve the problem.

 I need to access child's controls in child's code behind, something like this:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        Dim ctr As Web.UI.Control
        Dim editmode As Boolean = False

        Select Case Request.Params("editmode")
            Case "S", "s"
                editmode = True
            Case "N", "n"
                editmode = False
        End Select

        For Each ctr In Me.Controls
            If ctr.GetType().Equals(GetType(HyperLink)) AndAlso ctr.ID.Contains("_ResourceHyperLink") Then
                ctr.Visible = editmode
            End If
        Next
       
    End Sub

But Me.Controls brings MasterPage?s controls.

scott@elbandit.
Asp.Net User
Re: Controls in a Child Page11/29/2007 12:20:52 PM

0/0

Try accessing the controls collection in the content place holder:

Me.ContentPlaceHolder1.Controls


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

Scott ASP.net blog

scott@elbandit.
Asp.Net User
Re: Controls in a Child Page11/29/2007 12:23:06 PM

0/0

Gustavo Villa:
For Each ctr In Me.Controls
            If ctr.GetType().Equals(GetType(HyperLink)) AndAlso ctr.ID.Contains("_ResourceHyperLink") Then
                ctr.Visible = editmode
            End If
        Next


Change to:

For Each ctr In Me.ContentPlaceHolder1.Controls
       
If ctr.GetType().Equals(GetType(HyperLink)) AndAlso ctr.ID.Contains("_ResourceHyperLink") Then
               
ctr.Visible = editmode
       
End If
Next



 


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

Scott ASP.net blog

naturehermit
Asp.Net User
Re: Controls in a Child Page11/29/2007 1:09:07 PM

0/0

Hi There,

First of Master Page is no, Master or neither a Parent page and nor does the Content Page a child page as Master page is a type of user control and at runtime they are all merged.

To access controls in content page you can access them directly, unless they are in another container, in which case you need to follow the hierarchy.

If you tell us, what control you are trying to acces in the child page with its aspx, perhaps we (me and others answering here) can help


Please Mark Post that helped you as answer, also include a summary of what solved the problem as it helps others in similar situations
Gustavo Villa
Asp.Net User
Re: Controls in a Child Page11/29/2007 2:01:41 PM

0/0

Hi,

I need to change the visible property of all HyperLinks in the Child Page, so I can't use the ID directly.

But finally I have solved doing this:

For Each ctr In Me.Form.FindControl("ContentPlaceHolder1").Controls
       
If ctr.GetType().Equals(GetType(HyperLink)) AndAlso ctr.ID.Contains("_ResourceHyperLink") Then
               
ctr.Visible = editmode
       
End If

Thank you all. 


 

scott@elbandit.
Asp.Net User
Re: Controls in a Child Page11/29/2007 2:16:01 PM

0/0

Did this not work then?

For Each ctr In Me.ContentPlaceHolder1.Controls
       
If ctr.GetType().Equals(GetType(HyperLink)) AndAlso ctr.ID.Contains("_ResourceHyperLink") Then
               
ctr.Visible = editmode
       
End If
Next


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

Scott ASP.net blog

Gustavo Villa
Asp.Net User
Re: Controls in a Child Page11/29/2007 3:36:07 PM

0/0

 

No, in Child.aspx.vb I got the alert ContentPlaceHolder1 is not member of Child.

Thanks! 


 

scott@elbandit.
Asp.Net User
Re: Controls in a Child Page11/29/2007 3:48:16 PM

0/0

Sorry my code was running from the MasterPage code behind - sorry I misread the post Embarrassed


--------------------------------------------------------
Don't forget to click "Mark as Answer" on the post(s) that helped you.

Scott ASP.net blog

mnirmala@hotmai
Asp.Net User
Re: Controls in a Child Page12/5/2007 8:34:58 PM

0/0

Hi all, 

How do I access child textbox control id in master page javascript

 

Thanks

Nirmala 

Gustavo Villa
Asp.Net User
Re: Controls in a Child Page12/6/2007 12:32:28 PM

0/0

Hi, 

 ?Do you mean within a javascript tag in the Master Page aspx file?

mnirmala@hotmai
Asp.Net User
Re: Controls in a Child Page12/6/2007 2:22:28 PM

0/0

 Yes.  I did extensive search and looks like it is not possible.  Now we are trying to add that javascript in codebehind of child page.  The tricky part is, it should trigger onload event which we usually call like <body onload="resulttest();">.  Where we want to show a progress bar in javascript until the page is uploaded based on the textbox control value , as it is a long page.  But body tag is not available in child page.  Any suggestions please.

Thanks

 

Nirmala 

Gustavo Villa
Asp.Net User
Re: Controls in a Child Page12/6/2007 3:34:01 PM

0/0

 

When the server responses, the page (master and child) is sended as one to the browser, maybe you can look at the page's code (browser utility) to know what ID was given by the server for the textbox, and use this ID to find your control with the method getElemementById of the document object. Something as the following:

<script type="text/javascript">
function getValue()
{
var x=document.getElementById("MyTextbox");
  	var ProgressTicks = x.value;
	...
	...
}
</script>

 I hope it helps.

mnirmala@hotmai
Asp.Net User
Re: Controls in a Child Page12/6/2007 7:31:12 PM

0/0

 Hi Gustavo,

Thank you for responding to my queries.  Finding the Id of the control was the tricky part.  We got the id by doing something like document.getbyElementId(document.aspnetForm._ct100_contentplaceholder1_controlId. And in the child page we were writing the javascript above the contentholder and it was erroring out.  After we included the script inside the contentholder it works fine. 

Thanks lot.

Nirmala 

15 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
The Complete Idiot's Guide to Computer Basics Authors: Joe Kraynak, Pages: 423, Published: 2004
Alan Simpson's Windows Vista Bible Authors: Alan Simpson, Todd Meister, Pages: 1176, Published: 2007
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Professional ASP.NET 2.0 Databases Authors: Thiru Thangarathinam, Pages: 504, Published: 2007
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006
Macromedia ColdFusion MX 7 Web Application Construction Kit: web application construction kit Authors: Ben Forta, Raymond Camden, Leon Chalnick, Angela C. Buraglia, Pages: 1440, Published: 2005
ASP.NET AJAX Programmer's Reference: With ASP.NET 2.0 Or ASP.NET 3.5 Authors: Shahram Khosravi, Pages: 1522, Published: 2007

Web:
Parental Controls and Online Child Protection: A Survey of Tools ... Parental Controls & Online Child Protection: A Survey of Tools & Methods Version 3.1 ... Read this doc on Scribd: Parental Controls and Online Content ...
Online Child Safety - Windows Vista Parental Controls - Microsoft ... Aug 14, 2007 ... Time limits control in Windows Vista Parental Controls. 3. Click On, enforce current settings, and then click OK. Child's user controls page ...
built-in-page-controls [SilverStripe Documentation] Sep 1, 2008 ... Note for advanced users: These built-in page controls are .... Will return true if you are on the current page OR a child page of the page. ...
SSRN-Parental Controls & Online Child Protection: A Survey of ... Sep 16, 2008 ... SSRN-Parental Controls & Online Child Protection: A Survey of Tools & Methods by Adam ... This page was served by apollo 6 in 0.313 seconds.
Pass value from Child page to Parent page ( to locate sub controls ... Is there a way thru vb.net i can update or access my parent page controls from the child page. Important thing to note. ...
Starfish Family Mail - Kid safe email client controls what your ... Oct 27, 2004 ... The key thing is that if an email address is not on the list, it can't be seen by your child. So, this is a perfect program for children and ...
How to get the controls from master page to child page ... I wnt to get the controls from master page to child page. anyone of u know plz help me. my project flow is. Master page | Content page ...
Parent and Child Custom Controls on ASP.NET page - Dev Articles Parent and Child Custom Controls on ASP.NET page- .NET Development. Visit Dev Articles to discuss Parent and Child Custom Controls on ASP.
How to chnge page content of child tab controls? - Karamasoft ... Are your child controls UltimateTabstrip components or other server controls? If you reply with some sample code and explain in more detail which controls ...
getting child controls of a user control WriteControls(Page) end sub private sub WriteControls(parent As Control) for each child as Control in parent.Controls if child. ...

Videos:
Loose Ties #1/4, Mobile Modular All-Gauge Model RR Display This video (Part 1/4) shows the Loose Ties Model RR Club "Mobile Modular All-Gauge Train Display" operating in December 2006 near its hometown of ...
The Federal Reserve "If the American people ever allow private banks to control the issuance of their currency, first by inflation and then by deflation, the banks ...
Proyecto Ceibal 3 with English subtitles Video on the evolution of the Ceibal project. Part 3 of 3
Stalker - Sidney York winner of 'BEST SONG -- UNTAPPED NEWCOMER' category of 2008 Songwriting Contest presented by Calgary Folk Music Festival and the Ship & Anchor Pub ...
MeKenna Sharee Brown This is a 25 second video of my daughter, then the rest is a Memorial/Tribute video for a few angels. I will name the girls, give you a link to ...
Sonic 1 Hack: Mobius Adventures A playthrough of the first 2 levels (Green Hill/Marble Zone) of this Sonic the Hedgehog hack. Enjoy. Description taken from sonicretro.org ...
Hiryu Redesign 2008 Instead of having to flip pages and point at things on the sketchbook's page that only I can see, this time I decided to communicate a costume ...
WCN # 165 - World Chess News - ( Mitt i Schack ) This episode contains of: * "Chess a Moment" is the new mobile game * The world championship in Mexico * ACP demands standardizing time ...
New World Order is The Reason Our Society is Fucked Up IMPORTANT: CLICK *MORE* UAFF: FEMA CAMP WATCH PAGE http://www.uaff.us/deathcamps.htm The New World Order is the reason today why our whole ...
DADDY LOVES YOU (UPDATED VERSION INSIDE) THIS IS A SLIDE SHOW TRIBUTE IS FOR ALL OF THE MEN WHO ARE DOING THE RIGHT THING BY BEING THEIR FOR THEIR CHLDREN. THIS IS ALSO DEDICATED TO THOSE ...




Search This Site:










retirieve users password in database

adapter for asp:image control

bug on www.dotnetnuke.com

signcode error

problem creating forgot password facility using forma authentication.

master pages and forms, how to alter the default button

problem publishing site

visual studio 2005 and frontpage 2003

looking for a cheap host for a server i can play with i.e. install longhorn, etc

can't install 4.0.1

intranet web app - ad group checking

how to put scrollbars? but header of the gridview are not included....how?

2.1.2: whois online and membership info?

manual of dnn

rolling my own vs. 2.0 membership provider

content page layout changes when opening a new window

about create wizard control with aspnetdb

specific view based on login

class in ascx is not defined

admin portion ot ibuy

containers title box height

store + msde + vs.net debug error

how to use ie web controls in web matrix or dreamweaver?

setting the width of a menuitem

purging master page output?

sourcecode examples for webparts development

fail to get //loclahost/portalvbvs running

specified cast is not valid

custom type won't work in profile properties

conditional login????

 
All Times Are GMT