User control events

M

Miguel

Hi
I have builded some user controls in asp.net and works fine. These contros
have public properties, that I can view and modify at design time in the
properties panel. Both, properties and events, have the
[System.ComponentModel.Browsable(true)] attribute.
But, the events don't appear in de properties panel.

Also the [System.ComponentModel.DefaultValue("MyValue")] attribute for the
properties have not effect and I must assign these values at runtime

Any Idea?

best regards
Miguel
 
B

Bora

Hi Miguel,

Just a guess, in propertygrid events are displayed seperately from
properties (the lightning icon in propertygrid's toolbar). You might be
missing looking there. If not, would be nice if you send the code you wrote
for the event.

In a simple explanation, DevaultValue is used by Visual Studio if to write
value to aspx page or not. values different than DefaultValue will be
written to aspx page (which are bold in propertygrid). You should set
default value by yourself (like below for example.)

private string myPropertyDefault = "default";
public string MyProperty
{
get
{
object o = ViewState["MyProperty"];
return o==null ? defaultMyProperty : o as string;
}

set
{
ViewState["MyProperty"] = value;
}
}

Bora
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top