all groups > asp.net building controls > august 2003 >
You're in the

asp.net building controls

group:

Custom Controls and Type Properties not saving in html tag


Custom Controls and Type Properties not saving in html tag Luciano Criscola
8/25/2003 12:52:29 AM
asp.net building controls:
Hi all,

I am building a custom control and I add one primitive type (MyProperty1)
and one MyClass type (MyProperty2) as public properties

I had to make MyClass implement the IComponent interface so it would show
properly in the properties window ( It show the name of the property and a +
sign with al the properties of MyClass as children)

When a make some change in the properties window to MyProperty1, the new
values are reflected int the HTML view MyProperty1="MyValue" but when I do
the same with the object property instead of seeing
MyProperty2-MyProperty3="MyValue" I see nothing. But if I add manually
MyProperty2-MyProperty3="MyValue" in the HTML view, I see the change in the
property window.

Did I make my self clear...??
Well thanks anyway.

Here is the code

//--- B E G I
N---------------------------------------------------------------------------
---------------------------------
using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace MyNameSpace
{
public class MyClass :IComponent
{
private string myProperty3= "";
private string myProperty4= "";

public string MyProperty3
{
get {return myProperty3;}
set {myProperty3=value;}
}
public string MyProperty4
{
get {return myProperty4;}
set {myProperty4=value;}
}

#region IComponent Members

public event System.EventHandler Disposed;

public ISite Site
{
get
{
// TODO: Add MyClass.Site getter implementation
return null;
}
set
{
// TODO: Add MyClass.Site setter implementation
}
}

#endregion

#region IDisposable Members

public void Dispose()
{
// TODO: Add MyClass.Dispose implementation
}

#endregion
}


public class MyCustomControl :DataGrid
{
private string myProperty1="";
private MyClass myProperty2= new MyClass();

public string MyProperty1
{
get {return myProperty1;}
set {myProperty1=value;}
}

public MyClass MyProperty2
{
get { return myProperty2 ;}
set { myProperty2=value;}
}
}
}
//----E N
D---------------------------------------------------------------------------
--------------------------------------

Bye.

Luciano.

Re: Custom Controls and Type Properties not saving in html tag Teemu Keiski
8/25/2003 8:37:37 AM
In normal scenario if you want your control to be visible in the editor and
the HTML persisting etc to work like it is intended for controls, your
control would need to derive from System.Web.UI.Control or
System.Web.UI.WebControls.WebControl

About complex properties:
-They need to be read-only and instantiated when the property is first time
accessed (lazy instantiation)
-Have NotifyParentProperty(true) attribute applied
-Have
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
attribute applied

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com


"Luciano Criscola" <lcriscol@fibertel.com.ar> kirjoitti viestissä
news:uRUpRxraDHA.2016@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Re: Custom Controls and Type Properties not saving in html tag Luciano Criscola
8/25/2003 8:46:36 AM
Teemu ,
DesignerSerializationVisibility(DesignerSerializationVisibility.Content) was
the key to make it work.

Thank you so much.

Luciano.

"Teemu Keiski" <joteke@NOSPAMaspalliance.com> escribió en el mensaje
news:uH85LrsaDHA.1488@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button