VS 2010 User Control - No Bindable Property?
Nov 27, 2011
When I add a user control which has bindable properties to an asp.net page I do not see its bindable properties on the designer's dialog box when I click the edit Data bindings on the Repeater-Listview
Code:
Imports System.ComponentModel
<System.ComponentModel.DefaultBindingProperty("Text")> _
Public Class UserControls_ucSpecialTextBox
Inherits System.Web.UI.UserControl
...
<EditorBrowsable(EditorBrowsableState.Always), _
[Code] ....
View 6 Replies
Similar Messages:
Sep 9, 2010
I am trying to create a User Control that accepts a generic List of CustomObject as a bindable property.
I'd like it to look a little somthing like this :
TabularReport.ascx
[Bindable (true)]
public IList<T> Source
{
get;
set;
}
protected void Page_Load(object sender, EventArgs e).........
View 1 Replies
Mar 24, 2010
I am using: .NET 2.0, VS2005
I customized a button from System.Web.UI.WebControls.Button (it is a Custom Control, NOT an User Control, no ascx file)the intention is to adding a OrderID property to the button, that can be bound to a datasource field.
Here is how this control is used in a aspx page:
[Code]....
Here is my definition of the MYButton class, it saved in a .vb file and placed in App_Code folder
[Code]....
Here is the code trying to use the OrderID in btnSave_Click()
[Code]....
The problem is OrderID is always returned as 0.
When first time page is loaded, and gridview is bind to a data source, I step through the code, and the OrderID property are set correctly, but after the postback caused by the button, the OrderID value has lost.
View 3 Replies
Sep 10, 2010
I've got a web site that has a master page and that master page (mpMaster that has a user control ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page
and on this page I have another user control (ucPageControl), I need to find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all?
View 5 Replies
Mar 22, 2011
i have 2 user control : uc1 and uc2. and i have button in uc2 i call button1, i want to set commandArgument of button1 from uc1, how can i do this?
View 5 Replies
May 28, 2010
i built a user control and i want to make one of its properties as a must, that's mean if you not supply this control when you create the control the project won't be compile, just like if you omit the runat="server" property.
View 17 Replies
Oct 28, 2010
I have a user control that has the following property
public string ReportID
View 6 Replies
Jul 10, 2010
I created one web user control with property named "ReadonlyField" with boolean datatype. I am able to use in my web pages and now i wanted to add a description to that property so that i dont need to explain each time to my team member what is that property's intention.
I got following snippet in c# but didnt find any equivalent in vb.net and also not sure whether it will work or not.
[Description("My Description")]
public int MyIntProperty
{
get {..}
set {..}
}
View 1 Replies
Jun 2, 2010
I have a user control with a WebDateTimeEdit server control on it (essentially a TextBox). I'd like to be able to set some of the server control's properties by way of the user control's markup or programatically. for example I have this defined on my user control:
[code]....
this blows up because WebDateTimeEdit1 is null.
is there any way I can make this happen? also can do I do this
myControl2 .Font.Size = FontUnit.Point(8);
where the Font property is read only on the server control?
View 2 Replies
Aug 19, 2010
I have a label on my master page (called mainMenu) that shows the number of items in a cart. The label wasn't getting updated when the cart was cleared until after an additional postback or redirect so I created a method on the master page called UpdateNumberOfItemsInCart to update the label text.
Using the MasterType directive on the Cart page allowing me to strongly type the master page, I can access the update method from the Cart page. There is a user control also named Cart that actually contains the 'clear cart' button so I setup an event on the user control also called UpdateNumberOfItemsInCart. I wire up the Cart control's event on the Cart page which then makes a call to Master.UpdateNumberOfItemsInCart();
So far so good except when I wrap the Cart control with an update panel the update to the cart count label doesn't happen.
[Code]....
View 4 Replies
Apr 16, 2010
I have a control that I want to be able to mark areas as editable. When a user enters a username and password, they can then edit these editable areas.One of the area to edit is the main content of the page. Since I want them to be able to edit this on every page, I have put the editable control into the master page, wrapped around the ContentPlaceHolder of the master page.I found out how to allow the parser to allow <prefix:tag></prefix:tag> rather than just ending it with />, but I can't figure out how to get the text within the tags to be accessible through something like a Text property. A prime example of this behavior is the Label control, where you can put <asp:Label>Hello!</asp:Label> and access Hello! through the .Text property in the code.
View 10 Replies
Apr 2, 2010
how to access a property on my parent page from a user control?
View 2 Replies
Jan 25, 2010
I have created a user custom control, and what I would like to do is to pass it the text value from a label where I can carry out some other processing.
View 2 Replies
Oct 28, 2010
I have a very simple user control with 5 radio buttons on it, and 3 properties (ID, RatingSetID, and Rating). On the initial load of the page they are on, the code acquires data and places the data into the 3 properties. However, when the submit button is clicked the page reloads and the 3 properties get reset to 0, they are in the !IsPostBack as well.
View 2 Replies
Nov 29, 2010
I have a custom user control UserProfileLink on which I have two basic string properties, UID and UserFullName which I would like to use in a template column in a DataGrid like this:
....
<ItemTemplate>
<td:UserProfileLink ID="uplUser" runat="server" UID="<%#Eval("UserUID") %>" UserFullName="<%#Eval("UserFullName") %>" />
</ItemTemplate>
....
I get an error saying "The server tag is not well formed" which leads me to believe this type of binding isn't possible. Is there a way to do this, or is it impossible?
View 1 Replies
Feb 2, 2010
I have a web user control (ascx) that exposes an "ID" property. What I want to do is set this property when the SelectedIndexChanged event fires in a gridview in the containing page. However, I can't seem to do it.... Here's my code:
protected void grdPhysicians_SelectedIndexChanged(object sender, EventArgs e)
{
physicians_certif1.mdID = grdPhysicians.SelectedDataKey.ToString();
mvData.SetActiveView(viewEdit);
panAdditional.Visible = true;
}
Physicians_certif1 is the user control. It seems the user control is loading before the SelectedIndexChanged event has a chance to set it's property.
View 2 Replies
Aug 20, 2010
I have a user control with a panel on it:
CustomControl.ascx
<%@ Control Language="vb" CodeBehind="CustomControl.ascx.vb" %>
<asp:Panel ID="myPanel" runat="server"></asp:Panel>
I'd lke to expose that panel as a property that I can use at design time.
CustomControl.ascx.vb
<ParseChildren(True), PersistChildren(False)> _
Partial Public Class CustomControl
Inherits System.Web.UI.UserControl
#Region "Members and Properties"
<PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property SomePanel() As Panel
Get
Return myPanel
End Get
Set(ByVal value As Panel)
myPanel= value
End Set
End Property
#End Region
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Write(myPanel.HasControls.ToString())
End Sub
End Class
And then bring the control onto a page like so:
<ucl:CustomControl runat="server">
<SomePanel>
<asp:Label ID="lblText" AssociatedControlID="txtBox" runat="server"></asp:Label>
<asp:TextBox id="txtBox" runat="server"></asp:TextBox>
</SomePanel>
</ucl:CustomControl>
When I run the page, HasControls is true but nothing is rendered. What am I doing wrong?
View 1 Replies
Feb 23, 2010
I designed a user control. It contains a public property "CurrentValue". When I try to initialize the property using an Eval expression, a null value is assigned.
// In below code, label assignment is OK, RatingNull user control assignment get null
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Difficulty") %>'
<uc1:RatingNull ID="RatingNull1" runat="server" CurrentValue='<%# Eval("Difficulty") %>' />
</ItemTemplate>
If I directly assigned a value (ie, CurrentValue="5"), user control works fine.
public partial class RatingNull : System.Web.UI.UserControl
{
private string _CurrentValue;
public string CurrentValue
{
get { return _CurrentValue; }
set { _CurrentValue = value; }
}
(...)
View 1 Replies
Dec 3, 2010
Before I get to the question, let me give a bit of background. I'm trying to develop a custom caching mechanism that I can apply to custom built user controls. (Please be aware that I know that there are some built in caching mechanism in .NET) Depending on certain flags set declaratively in the mark-up the control should load a cached version of its previously rendered content or execute normally (and if certain flags are set it should generate a cache of its content for next time it loads). I would like to be able to pass certain flags declaratively in the mark-up and being able to check their value at Page Init and, depending on the flag value, determine whether the control should load a cached version or not.
<uc:MyUC ID="N1" runat="server"
CacheProp='<%# SomeEnum.A | SomeEnum.B |SomeEnum.C %>'
PropA='<%# this.SomePropA %>'
PropB='<%# (this.SomePropB %>'
PropC='<%# this.SomePropC %>'
/>
The problem that I'm facing is that as far as I'm aware I can only get the value of the properties declaratively assigned in the mark-up if I called the DataBind(). However I'm faced with two problems: Firstly calling this.DataBind() from within MyUC will trigger the binding of all its child controls which would defeat the purpose of the cache; also all user controls have been built so that they will not call DataBind() before the LoadComplete event has fired, so to make sure that the parent controls they live in has done its initialisation and has computed the properties that are declaratively passed to the child user control (ie PropA, PropB, PropC).And now the question: is there a way to bind the CacheProp property so to retrieve its value without data binding all other properties and without triggering the data binding of all its child controls?
View 1 Replies
Apr 13, 2010
I'm having trouble to access a Parent's property in User Control. I don't know how to access the parent. The Parent Page's name is Search.aspx. I saw the example below and tried it:
[Code]....
Than I could access the Parent's Property, but when I ran the website I got these errors:
1. The user control is not declared in the parent page
2. The user contol has a circular reference
View 3 Replies
Oct 25, 2010
I have a hidden field on my default.aspx page. Within default.aspx page I have a user control which has a label on it. I need the label to display the value on the hidden field. How can I go about this?
View 1 Replies
Apr 15, 2010
I am trying to build a web user control and set some default values for its properties in the code-behind like this:
[DefaultValue(typeof(int), "50")]
public int Height { get; set; }
[DefaultValue(typeof(string), "string.Empty")]
public string FamilyName { get; set; }
[DefaultValue(typeof(Color), "Orange")]
public System.Drawing.Color ForeColor { get; set; }
When I add the user control to the page and call it without any properties:
<uc1:Usercontrol ID="uc" runat="server" />
the default values are not set and every property is 0 or null.
View 2 Replies
Jun 10, 2010
I created user control. It has string[] public property (it may be List<string> or whatever). I want to support defining this property in aspx code, when declaring the instance of this usercontrol. Something like this:
<uc1:MyControl ID="MyControl1" runat="server">
<MyStringCollectionProperty>
<string>My String 1</string>
<string>My String 2</string>
[code]...
View 3 Replies
Jan 3, 2011
I would like to dynamically load a user control and assign one of its public properties OnLoad...
I'm doing the following from a parent user control to dynamically load the child user control...
UserControl uc = (UserControl)Page.LoadControl("~/Controls/MyUserControl.ascx");
What else do I need to do to pass a value so its public property is set OnLoad?
View 3 Replies
May 4, 2010
I have a web page with several databound (via their property's) user controls in a multiview in a formview.
I decided to try Ajax (Adding ScriptManager, updatepanel etc).
All works fine except for the user controls.
The controls I use to contain the usercontrol property values ((invisible) Textboxes or Hidden fields) lose their value when i change from ond multiview panel to another. (In other words: usercontrols on invisible multiview panels lose their property value's). (When I change a multiviewpanel all the property fields turn emty, when i hit the update button of the formview afterwards the emty values are propagated to the database. (resulting in loss of data)) Textbox seems to hold its value, hiddenfield loses its value (when changing from one multiview panel to another).
This seems to be a coplication of the multiview in combination with ajax.
View 1 Replies