473,480 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

UserControl Property Grid

I have created the following usercontrol

public class RegisterUser : TemplatedWebControl {
private VisFields _vfields = new VisFields();
public VisFields VisibleFields {
get { return _vfields; }
set { _vfields = value; }
}

private bool _showit;
public bool ShowIt {
get { return _showit; }
set { _showit=value;}
}

public RegisterUser() : base() {
}
VisFields is a custom class that has properties of boolean
[TypeConverter(typeof(VisFieldsConverter)), Description("Select Visible
Fields")]
public class VisFields {
private bool _firstQuestion;
private bool _secondQuestion;

[DefaultValue(true)]
public bool FirstQuestion {
get { return _firstQuestion; }
set { _firstQuestion = value; }
}

[DefaultValue(true)]
public bool SecondQuestion {
get { return _secondQuestion; }
set { _secondQuestion = value; }
}

}

if have of also implemented VisFieldConverter
public class VisFieldsConverter : ExpandableObjectConverter {
..
..
..
}

When i drag and drop the control into my webpage, and click on the
property grid, i see the (VisibleFields) property and i can expand it
and see its properties (FirstQuestion,SecondQuestion). I can change
them to true/false, but when i switch to source of design mode, or even
when i run the page, these properties always have their default value.
So the problem is that the control CAN'T keep the changes i make from
design mode. Any ideas??

Jan 18 '07 #1
1 1702
If you want to keep the values in the properties, you should use ViewState
for that.

public bool SecondQuestion {
get {
if(ViewState["SecondQuestion"] != null)
return
Convert.ToBoolean(ViewState["SecondQuestion"]);
return true;
}
set { ViewState["SecondQuestion"] = value; }
}
It works fine. :)
<ma******@gmail.comwrote in message
news:11**********************@a75g2000cwd.googlegr oups.com...
>I have created the following usercontrol

public class RegisterUser : TemplatedWebControl {
private VisFields _vfields = new VisFields();
public VisFields VisibleFields {
get { return _vfields; }
set { _vfields = value; }
}

private bool _showit;
public bool ShowIt {
get { return _showit; }
set { _showit=value;}
}

public RegisterUser() : base() {
}
VisFields is a custom class that has properties of boolean
[TypeConverter(typeof(VisFieldsConverter)), Description("Select Visible
Fields")]
public class VisFields {
private bool _firstQuestion;
private bool _secondQuestion;

[DefaultValue(true)]
public bool FirstQuestion {
get { return _firstQuestion; }
set { _firstQuestion = value; }
}

[DefaultValue(true)]
public bool SecondQuestion {
get { return _secondQuestion; }
set { _secondQuestion = value; }
}

}

if have of also implemented VisFieldConverter
public class VisFieldsConverter : ExpandableObjectConverter {
.
.
.
}

When i drag and drop the control into my webpage, and click on the
property grid, i see the (VisibleFields) property and i can expand it
and see its properties (FirstQuestion,SecondQuestion). I can change
them to true/false, but when i switch to source of design mode, or even
when i run the page, these properties always have their default value.
So the problem is that the control CAN'T keep the changes i make from
design mode. Any ideas??

Jan 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2448
by: Steve | last post by:
Hi, I have a UserControl which I would like the user to be able to configure through the property grid at runtime. How can I hide certain properties that you get as standard such as Anchor and...
0
1970
by: Colin Ramsay | last post by:
Hi all, I don't normally post swathes of code like this but I am truly banging my head off my desk here... I've dynamically created a datagrid within a usercontrol. There are two columns...
6
1965
by: Anonymous | last post by:
Hello, I am loading a usercontrol with the LoadControl method and need to pass some data to the property of that control. How can I do that? THanks
6
1913
by: Pete Davis | last post by:
I'm fairly weak with ASP.NET. What I'm trying to do is pass an attribute to a UserControl. The attribute is a value from the CodeBehind for the page. So in my .aspx I have the following: ...
0
823
by: elziko | last post by:
I have a UserControl inside my project. When I click on the UserControl in the design view I get to also view all its properties in the property grid. I the change the AllowDrop property to True. ...
7
2499
by: steve.kaye | last post by:
I am writing a number of controls which use inheritance and I have a problem that I do not know how to solve. It's best if I describe the class structure I want. Grid - derives from UserControl...
0
2521
by: osmarjunior | last post by:
Hi. I have a UserControl with a DataGridView and 3 buttons (New, Edit and Delete) inside. I wanna do something like that: when the focus leaves the UserControl, it hides the selection of the...
2
2805
by: Mark Collard | last post by:
The ToolBar control allows you to add toolbar buttons. When you add a button, the button is not only displayed in the toolbar, but also added as a separator control in the form/usercontrol your...
6
12115
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7059
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4499
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.