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.
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?
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:
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?
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?
I reference a user control in my ListView in this manner:
[Code]....
The problem is that the #Bind command doesn't update the database, but it does so when I paste the code directly into the aspx page (in other words, without the user control involved).
I am trying to bind two values "start_time" and "end_time" to a text property of a label that is inside of a gridview template field. Below is the html. I must keep the values separate so that I can pass them into a function in code beheid in order to calulate the time difference. When I bind the code below I get "The server tag is not well formed." Time is in format HH:MM AM or PM
I would rather not magic string my DataTextField/Values on the dropdownlist after setting up the source as a List collection of objects.
I was thinking I could use the DataSource properties but it doesn't seem to like the couple of ways I tried.
WORKS BUT NOT IDEAL //set the datasource to the returned List<Cart> this.cartDdl.DataSource = CartManager.Load(WebProfile.Current.UserName); //set the DataValueField to the Cart.ID property this.cartDdl.DataValueField = "ID";//would rather use the obj property Cart.ID //set the DataTextField to the Cart.Description property this.cartDdl.DataTextField = "Description";//would rather use the obj property Cart.Description //Bind the ddl to the datasource this.cartDdl.DataBind(); HOW I WOULD THINK IT COULD WORK this.cartDdl.DataValueField = ((Cart)this.cartDdl.DataSourceObject).ID; this.cartDdl.DataTextField = ((Cart)this.cartDdl.DataSourceObject).Description;
I got 15 tabs and 15 user controls assigned to each tab.All are loading at once which id delaying the process. I want to load one user control on selection of a tab in tab container.
I have a user control that contains an image of a product along with some product details.
If the product image is landscape, I want to render the control one way, and if the product image is portrait, I want to render the control a second way.
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.
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 {..} }
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?
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.
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.
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.
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:
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
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
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), _
I am having a very hard time in consuming a very simple web user control that I have built using a Web Application project in VS 2010. The user control works fine as long as the consuming aspx page is in the same project. But after deploying the project using Web Deployment Project into a single assembly I am not able to use it correctly from another aspx page which is in a stand-alone project. The error I see is a null reference exception. Here are the steps that I am following:
1 Create a web user control named WebUserControl_Label using a web application project. This control works fine when used in an webform in the same project.
namespace TestWebAppWithCustomControl { public partial class WebUserControl_Label : System.Web.UI.UserControl { private string _labelText; public string LabelText { set { Label1.Text = value; } get { return Label1.Text; } } protected void Page_Load(object sender, EventArgs e) { } } }
2. Create a single assembly for the user control above using a Web Deployment project. The name of the assemby is TestWebAppWithCustomControl.
3. Create a webform in another web application project to use WebUserControl_Label user control. This project has TestWebAppWithCustomControl.dll added as a referemce.
This is how I am using the custom control above in an aspx page:
The problem is that .NET throws a Null Reference Exception when its trying to set the label text via the LabelText property. It looks like that the label control that lives inside the WebUserControl_Label user control is not getting instantiated and is always null.
I have found a few articles online that talk about creating such distributable user controls using ASP.NET website projects. But if possible I would like to stick with the web application project because of the benefits it brings.
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
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?