Custom Server Controls :: Property Not Being Held In ViewState?

Mar 11, 2010

I have the following class:

[Code]....

It was my expectation that by default, the Title property would be stored in ViewState, but this appears not to be the case - the exception in RenderBeginTag keeps getting thrown on postback.

Am I being thick? Do I need to explicitly store properties in ViewState?

View 4 Replies


Similar Messages:

Custom Server Controls :: Binding UserControl Property To Page Property?

Sep 15, 2010

So what I'm trying to accomplish is this

[Code]....

The user control has public properties named accordingly and the page has protected properties accordingly which I've verified have the desired values.

For some reason the values are always empty strings or 0s in the usercontrol, no matter what the page property is.

View 1 Replies

Custom Server Controls :: How To Add A Dropdownlist Of Available Values For A Custom Server Control Property

Sep 13, 2010

How would I add a (dropdown) list of available values for a custom server control property?

(Just like 'Visible' property of most controls has valid values of 'True/False' and nothing else can be entered or selected)

View 3 Replies

Property From A Custom UserControl That Is Saved In Viewstate Loses Its Value?

Jul 28, 2010

I have a custom control in an aspx page that has a property named Size

public int Size
{
get { return Convert.ToInt32(ViewState["CreativeSize"]); }
set { ViewState["CreativeSize"] = value; }
}

This property is set in the aspx page to a value lets say 500 during a postback called by a Button control that is in the page (not in the custom control).

I also have a button inside the custom control that raises a postback like this

protected void btnUpload_Click(object sender, EventArgs e)
{
if (fuBannerfile.HasFile)
if (fuBannerfile.FileContent.Length / 1024 > this.Size)
;//code here not important
}

When this event is called the "this.Size" property is 0. I also noticed during debugging that during Page_Load of the page, if i access the property like this:

int size = customControlId.Size;

the property is set to 500. But after that when the debugger reaches the event inside the control the property is 0.

View 1 Replies

Custom Server Controls :: How To Create Custom Property (DataSource) In Custom Controls

May 15, 2010

I know that how to create custom control and add custom property.

I want to create property like DataSource to my custom control.

View 1 Replies

Custom Server Controls :: Insert A Drop List Property Into A Custom Webcontrol?

Feb 18, 2010

How insert a drop list property into a custom webcontrol? This a drop list property is show all textbox control on usercontrol or webpage.

View 3 Replies

Custom Server Controls :: Custom Checkbox Control 'checked' Property Is Not Working?

Sep 3, 2010

Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.

public
class
TngCheckBox :
CompositeControl
{

i have written the required properties which are working fine except the "checked" property. here is my code for 'checked' property. i tried both the below ways (commented one and not commneted) . the problem is the 'checked' value is not setting the value at the get set part of the property.its assigning the value at the design time , but when i check and uncheck its not updating the property value.which is resulting me wrong .

[Code]....

View 2 Replies

Custom Server Controls :: Custom Checkbox Control 'checked' Property Is Not Working ?

Oct 15, 2010

Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.

public
class
TngCheckBox :
CompositeControl
{

i have written the required properties which are working fine except the "checked" property. here is my code for 'checked' property. i tried both the below ways (commented one and not commneted) . the problem is the 'checked' value is not setting the value at the get set part of the property.its assigning the value at the design time , but when i check and uncheck its not updating the property value.which is resulting me wrong .

[Code]....

View 4 Replies

Custom Server Controls :: List Property Of A Custom Control Is Not Persisted?

Mar 15, 2010

I have a custom control, inherited from Button. This is the class definition for the control and 2 properties:

[Code]....

I show you 2 properties, only to illustrate the problem.

as you see Aplicacion property is of a custom type Sistema, and Roles property is of type List<UserRol>.

The Aplicacion property is rendered well, this way:

[Code]....

The problem I have is with List<UserRol>. I couldn't get it to be rendered. I expeect to be rendered this way:

[Code]....

Finally, this is the TypeConverter and Editor definitions for the list:

[Code]....


The UserRol class is a typical class, without any special attributes.

I have discovered that when I use the custom editor for Roles property, the collection is not persisted. When I use the default editor for the collection, the collection is persisted.

View 1 Replies

Custom Server Controls :: Need Custom Text Box Control With DataSource,TableName,ColumnName Property?

Nov 26, 2010

I need to create one custom text box control which should be bind with data base.

I am referring following link...

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.databoundcontrol.aspx

I used DataBoundControl to create my control but i am not able to do it properly.

public class SimpleTextBoxControl : DataBoundControl
{
private TextBox nameTextBox;
public string DataTextField
{
get
{
object o = ViewState["DataTextField"];
return ((o == null) ? string.Empty : (string)o);
}
set
{
ViewState["DataTextField"] = value;
}
}
[
Bindable(true),
Category("Data"),
DefaultValue(""),
Description("The text to display on the link."),
Localizable(true),
PersistenceMode(PersistenceMode.InnerDefaultProperty)
]
public virtual string DataTexValue
{
get
{
string s = (string)ViewState["Text"];
return (s == null) ? String.Empty : s;
}
set
{
ViewState["Text"] = value;
}
}
protected override void PerformDataBinding(IEnumerable retrievedData)
{
if (retrievedData == null)
return;
base.PerformDataBinding(retrievedData);
Controls.Clear();
nameTextBox = new TextBox { ID = "nameTextBox" };
foreach (object dataItem in retrievedData)
{
if (DataTextField.Length > 0)
{
nameTextBox.Text = DataBinder.GetPropertyValue(dataItem, DataTextField, null);
}
DataTexValue = nameTextBox.Text;
}
this.Controls.Add(nameTextBox);
}
}

View 1 Replies

Custom Server Controls :: How To Custom Controls Derived From Existing Controls - Overriding Default Property Values

Nov 15, 2010

I have some (probably very basic) questions about developing custom controls. I am wanting to derive a set of button controls, and the first one I have started on is a "DeleteButton", that has a additional property (DeleteConfirmationText) that is built into the OnClientClick attribute. To get that added, I overrode the Render method as follows:

[Code]....

This all works well. Now, I will add some logic to make sure that there is some text in the DeleteConfirmationText property, but that isn't the intent of my question.
What I am also wanting to do is to override some of the default property values, so I added that to the default constructor:

[Code]....

Now, in the designer in VS2008, and I look at the properties for the control, there isn't a default value shown in the "Properties" section, and the Causesvalidation still shows the underlying classes default value of "True". As well, in design mode, where the GridView control that containse my DeleteButton control would be displayed, there is an error box "There was an error rendering the control. 'Are you certain you want to delete this attorney?' cound not be set on property 'DeleteConfirmationText'. Here's the markup where I am defining the deletebutton control:

[Code]....

What am I doing wrong?

View 5 Replies

Custom Server Controls :: How To Set And Get Property For The Dropdown

Jul 21, 2010

In my user control i have the label1,textbox1 and dropdown1, i can able to set the values and get for both label and text box. but how can i set the value for the drop down.

from the aspx.cs or aspx.vb

i will set the object of the control (Ex: usercontrol1234)

usercontrol1234.propText="This is text box"
usercontrol1234.propLbl="This is Label "

Then how can i set for the drop down? i can bind the dropdown data either by dataset or datareader.But cannot able to figure out how to set the property?

[code]....

View 7 Replies

Custom Server Controls :: Composite Control Which Contains Arbitrary Content Defined In .aspx Of Parent And Thier ViewState

Aug 21, 2010

I want to write own control which can contain other. And I want to define content of the control in the .aspx file where the control is defined. I have written such control. But now I have issue with ViewState of inner controls of my control. The following samle illustrates the issue: I defined two asp:DropDownList ID="ddl1" and ID="ddl2" One of them is inside of my control and other is outside. When posback is occurred asp:DropDownList ID="ddl1 loses state and becomes empty. How to say ASP.net to store state of inner controls defined by this way?

MyControl.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyControl.ascx.cs" Inherits="DynamicControls.Controls.MyControl" %>

<div class="box"> [code]....

View 4 Replies

Custom Server Controls :: Get A Color Picker For A Property?

Feb 24, 2010

I would like to create a property that uses the Visual Studio color picker (just like ForeColor and BackColor).It seems I need something like this:

[Editor(typeof(ColorTypeEditor),typeof(UITypeEditor)) ]

But I am not able to find the correct syntax.I tried it without an editor and returning the type "Color", but that just generates a dropdown with all of the known color names for the property. I would like the color picker to appear which allows you to see the colors and pick one.

View 3 Replies

Custom Server Controls :: How To Show All Property Of Gridview Of Control

Jul 14, 2010

i have created a new user control who contains a gridview so, my prolem now is that i want show all the property of the gridview included in the control, but i want not write like this:"Usercontrol1.GridView1.Datasource=...." but i want write "Usercontrol1.DataSource=..." and this also for other controls how can i do this?

View 1 Replies

Custom Server Controls :: Populate Property Choices From A Database?

Aug 19, 2010

I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices, based off of that enum. But I'd like it to pull records from a database and populate the list of choices for the property from a database. This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.

View 3 Replies

Custom Server Controls :: Radio Button Grouping Property Is Not Working

Oct 20, 2010

Iam developing a custom server control of radiobuttton. it is working fine with the all the properties i wrapped except the grouping . somehow the grouping is not working .

[Code]....

View 6 Replies

Custom Server Controls :: Adding A CssClass Property To Web User Control?

Apr 26, 2010

The built in Asp.Net Controls (label, Textbox, etc.) all have a CssClass property that can be set, what do I need to do to implement that for a Web User Control?

I know how to add a property and pass thru the get & set to the corresponding Asp.Net control (example if I have a label I know how to create a LabelCssClass property that provides a get & set, but the control itself how do I set a CssClass or ClassName property.

View 4 Replies

Custom Server Controls :: Web User Control Doesn't Accept It's Property

May 22, 2010

[Code]....

When i add this control to a page i set it's address with Address property. But it never sets it's address property like this :

[Code]....

When i try it like above, it always set address null. So it never goes to webpage that i want. It's result in the address bar always like this :

http://localhost:4533/TarihKoruma/?Date=12.05.2010 but i want it like this :
http://localhost:4533/TarihKoruma/Events.aspx?Date=12.05.2010

View 6 Replies

Custom Server Controls :: Creating .NET UserControl With Collection-type Property?

Feb 21, 2011

How can I create a UserControl with a collection-type property which has a collection editor?

I've a CompositeControl with an ArrayList-type property which has CollectionEditor-type designer. You can see this property on Properties window with a "..." button which launches a collection editor. This works fine and all but I want to apply the same to a UserControl and I've couldn't manage to pull it off so far. I've done the same thing what I've done with my CompositeControl but the property either doesn't even show on Properties window of the UserControl or shows as a single value property with no "..." editor button.

This is what I've done with CompositeControl:

[Code]....

View 1 Replies

Custom Server Controls :: How To Set Default Height/Width Property Value Of Composite Control

Nov 3, 2010

How to set default Height/Width property value of Composite control

[Code]....

View 3 Replies

Custom Server Controls :: Find The Data Values Of The Fields Specified In The DataNavigateUrlFields Property?

Jan 27, 2010

I have created a class which inherits the HyperLinkField. I need to find the data values of the fields specified in the DataNavigateUrlFields property. I have not been able to figure out how to do this.

View 1 Replies

Add Custom Property To Custom Server Control?

Jan 11, 2011

I have created an asp.net custom control and now want to pass some values to it from the page which will use the control.Is there any way i can add my own property to the control (like Text property is present for a Label control)?

View 4 Replies

Web Forms :: Maintain Viewstate In Custom Server DropDownList?

Mar 13, 2011

I'm quite new to this so excuse me if this is a stupid question.

I created an extended dropdownlist based on the instruction on the asp.net site.

[URL]

My control gets a list of items from LINQ to SQL.

here's my problem:

When the page I used the control on posts back, the list get's re-initialized and looses it's selection.

How do I overcome this problem and keep the selection upon postback?

[Code]....

View 3 Replies

Custom Server Controls :: Category Attribute Of User Control Property Does Not Work Correctly In Categories Tab

Aug 19, 2010

I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Code]....

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved