in my ascx control, I have bool property marked as [Bindable(true)], but this property is not visible in designer - see on the picture
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.ComponentModel.Design;
[DefaultBindingProperty("SelectedValue")]
public partial class Controls_LabelAnoNe : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
[Bindable(true)]
public bool SelectedValue
{
get
{
if (lblAnoNe.Text == "Ne")
return false;
else return true;
}
set
{
lblAnoNe.Text = (value) ? "Ano" : "Ne";
}
}
}
I tried add this attributes above property, but no effect -
[Bindable(true)]
public bool SelectedValue
{
get
{
return lblAnoNe.Text == "Ne"; }
set
{
lblAnoNe.Text = (value) ? "Ano" : "Ne";
}
}
I think I can get that in the design panel in the property panel.
Mlsoun
Member
2 Points
19 Posts
[Bindable(true)] property is not visible in Designer
Aug 10, 2012 10:55 AM|LINK
Hello,
in my ascx control, I have bool property marked as [Bindable(true)], but this property is not visible in designer - see on the picture
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ComponentModel; using System.ComponentModel.Design; [DefaultBindingProperty("SelectedValue")] public partial class Controls_LabelAnoNe : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } [Bindable(true)] public bool SelectedValue { get { if (lblAnoNe.Text == "Ne") return false; else return true; } set { lblAnoNe.Text = (value) ? "Ano" : "Ne"; } } }I tried add this attributes above property, but no effect -
[Browsable(true)] [Bindable(true, BindingDirection.OneWay)] [DefaultValue("")] [PersistenceMode(PersistenceMode.Attribute)]Of course that i can bind data writing manualy expression, but it is not comfortable
<mts:LabelAnoNe ID="LabelAnoNe3" runat="server" SelectedValue='<%# Eval("Comment") %>'/>Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: [Bindable(true)] property is not visible in Designer
Aug 12, 2012 02:36 AM|LINK
Hi,
I think you can simplify your codes like this——
[Bindable(true)] public bool SelectedValue { get { return lblAnoNe.Text == "Ne"; } set { lblAnoNe.Text = (value) ? "Ano" : "Ne"; } } I think I can get that in the design panel in the property panel.Mlsoun
Member
2 Points
19 Posts
Re: [Bindable(true)] property is not visible in Designer
Aug 14, 2012 06:24 AM|LINK
not resolvet. Only if I make server control instead ascx, but still no resolved
Mlsoun
Member
2 Points
19 Posts
Re: [Bindable(true)] property is not visible in Designer
Aug 15, 2012 11:54 AM|LINK
It did not help.
Like other I tried change name of property from SelectedValue to SelVal but not effect :-(
Cathy Mi - M...
Member
741 Points
165 Posts
Microsoft
Re: [Bindable(true)] property is not visible in Designer
Aug 16, 2012 06:59 PM|LINK
Hi,
I'm thinking the following forum might be a better place for this question:
http://forums.asp.net/18.aspx/1?Web+Forms
Thanks,
Cathy Miller
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: [Bindable(true)] property is not visible in Designer
Aug 17, 2012 12:48 AM|LINK
many thanks but it would be better if move to Custom Control.
gtscdsi
Member
250 Points
50 Posts
Re: [Bindable(true)] property is not visible in Designer
Aug 17, 2012 07:13 AM|LINK
You cannot do that with user controls. You have to make custom user controls
http://blogs.msdn.com/b/asiatech/
Mlsoun
Member
2 Points
19 Posts
Re: [Bindable(true)] property is not visible in Designer
Aug 20, 2012 09:30 AM|LINK
make ASP.NET Server Control:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SrvCtrlAnoNe { [DefaultProperty("BooleanValue")] [ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")] public class ServerControl1 : WebControl { [Bindable(true)] [Category("Appearance")] [DefaultValue("")] [Localizable(true)] public bool BooleanValue { get { bool booleanValue = (bool)ViewState["booleanValue"]; return (booleanValue) ? true : false; } set { ViewState["booleanValue"] = value; } } protected override void RenderContents(HtmlTextWriter output) { output.Write(BooleanValue?"Ano":"Ne"); } } }Many thanks to all involved :-)
The other way via this workaround is solution