Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics 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 June 23rd, 2008, 04:56 AM
Authorized User
 
Join Date: Dec 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Binding properties to controls

Hi,

My control has a public property called 'DisableBackground'.
e.g.
Control.ascx.cs
Code:
private bool _disableBackground;
private string _targetControl;

public bool DisableBackground
{
  get { return _disableBackground; }
  set { _disableBackground = value; }
}
public string TargetControl
{
  get { return _targetControl; }
  set { _targetControl = value; }
}
I set the value on the property when I use the control from an aspx page.
e.g.
Default.aspx.cs
Code:
 <Controls:ModalWindow runat="server" TargetControl="btnTrigger" DisableBackground="true" />
I want to bind that property to the control
e.g.
Control.ascx
Code:
        <ajaxToolkit:ModalPopupExtender ID="windowExtender" 
         runat="server" 
         BehaviorID="window" 
         TargetControlID="<%# this.TargetControl %>" 
         PopupControlID="panelWindow" />
I know that in the code behind I can find the control and then assign a value to the property.
e.g.
Control.ascx
Code:
if (_disableBackground)
{
  AjaxControlToolkit.ModalPopupExtender popup = (AjaxControlToolkit.ModalPopupExtender)this.FindControl("windowExtender");
  popup.BackgroundCssClass = "modalBackground";
}
popup.TargetControlID = _targetControl;
I was wondering if there is a simple way I can just bind the property to the control. All the examples I can find bind repeating data to the control but I just want to bind a single property or a few properties.

Thanks in advance,

Paul
__________________
http://www.thewebsiteshop.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding Controls zulf Infopath 0 October 8th, 2007 11:22 PM
Binding controls Boris Kofman VB Databases Basics 1 January 20th, 2007 01:16 PM
Access templated controls properties tony_j_hug ASP.NET 2.0 Basics 5 October 17th, 2005 10:44 AM
Accessing Properties in User Controls andyj00 Classic ASP Professional 1 May 21st, 2005 02:52 PM
default properties on controls Duncan Pro VB.NET 2002/2003 3 November 15th, 2003 02:32 PM





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