.NETGURU
Simple User Control question...
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvs' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Michael R Kizer

I'm sure this is a simple question, but I haven't been able to locate a
good answer for it yet...

Let's say I have a User Control used for navigation that contains a series
of image buttons.
This User Control exists on every page for the website, but on certain
pages I wish to disable or hide some of the buttons.

How do I reference the properties of controls within a User Control from
the Page_Load event?

Thanks,
~Michael Kizer
Click here to reveal e-mail address

Reply to this message...
 
    
James Shaw (VIP)
Add a property to your UC, then set that in your pages Page_Load or in HTML
directly, like this:
(this is slightly weird in the way that I pass bools as strings, but it
allows use of the property in HTML as well as code)

// user control:
public abstract class myUC : System.Web.UI.UserControl
{
protected ImageButton myButton;

    public string ButtonOn
    {
        set { myButton.Visible = bool.Parse(value); }
    }
}

// page (method 1, in HTML)
<%@ Register TagPrefix="MyStuff" TagName="MyUC" Src="UserControls/MyUC.ascx"
%>

<MyStuff:MyUC runat="server" ButtonOn="false" />

// page (method 2, in Page_Load)
using MyStuff;
public class Default : Page
{
    protected MyUC myUC;

private void Page_Load(object sender, System.EventArgs e)
    {
        myUC.ButtonOn = false.ToString();
    }
}

James Shaw
http://CoverYourASP.com/
Download it. Run it. Learn it.
http://ASPRSS.com/
Publish ASP with RSS XML

-----Original Message-----
From: Michael R Kizer [mailto:Click here to reveal e-mail address]
Sent: Monday, August 12, 2002 7:26 PM
To: aspngvs
Subject: [aspngvs] Simple User Control question...

I'm sure this is a simple question, but I haven't been able to locate a
good answer for it yet...

Let's say I have a User Control used for navigation that contains a series
of image buttons.
This User Control exists on every page for the website, but on certain
pages I wish to disable or hide some of the buttons.

How do I reference the properties of controls within a User Control from
the Page_Load event?

Thanks,
~Michael Kizer
Click here to reveal e-mail address

| [aspngvs] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvs.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 
System.EventArgs
System.Web.UI.UserControl
System.Web.UI.WebControls.ImageButton




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification