CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: Date Entered: 10/7/2004 2:59:12 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 0 Views: 46 Favorited: 0 Favorite
1 Items, 1 Pages 1 |< << Go >> >|
"kl4" <>
NewsGroup User
solution : webcontrol & collections & ImageUrlEditor & design time10/7/2004 2:59:12 PM

0

ok,
after searching a lot I found a solution about this problem:

1 you made a webcontrol that have a property of type collection
that each object of this collection is not derived from webcontrol (e.g: it contains
a collection of a custom class)

2 in this custom class you have a property that need to be filled thru the ImageUrlEditor

3 all works EXCEPT that the ImageUrlEditor does not "popup" when you click on the property
or
an error is thrown

SOLUTION (C#)

----- Webcontrol Class ----

[
,ParseChildren(true)
,PersistChildren(false)
]
public class MyWebConrol : WebControl
{
MyCollection _itemlist;

[
,DesignerSerializationVisibility(DesignerSerializationVisibility.Content)
,PersistenceMode(PersistenceMode.InnerProperty)
,NotifyParentProperty(true)
]
public MyCollection Items
{
get{
if(_itemlist==null)
_itemlist=new MyCollection (this/* <--- here pass the webcontrol instance */);
return _itemlist;
}
}

}


------------- Collection Class -----------------

1 add a field of type object named "_parent" (for example) to the collection class

1 modify your collection class to inherit from Ilist and implement methods, especially Add and Remove


public class MyCollection: IList
{
object _parent=null;
private ArrayList _list=new ArrayList();

public MyCollection(object o)
{
_parent=o;
}

int Add(MyCustomClass o)
{
( (Control)_Parent).Controls.Add(o);
return _list.Add(o);
}


int IList.Add(object value)
{
if(value==null)
{
throw new ArgumentNullException("value","null reference exception");
}
MyCustomClass p=value as MyCustomClass ;
if(p==null)
throw new ArgumentException("value","Only objects of type MyCustomClass ");
return Add(p);
}
//---------- implementation of Ilist ......

}

------------- Custom Class -----------------
1 modify your custom class to inherits from Control (even if it doesn't need it)
because VStudio designer seems to accept to launch designers only if the object is derived from Control or WebControl !!!!

public class MyCustomClass: Control
{
string _pict="";

[
Editor(typeof(System.Web.UI.Design.ImageUrlEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string Picture
{
get {return _pict ;}
set { _pict=value ;}
}

// override this method if you don't produce HTML
protected override void Render(HtmlTextWriter output)
{
}


}

this should work !

Karim Laurent
1 Items, 1 Pages 1 |< << Go >> >|


Free Download:













process flow control

can anyone recommend a uk based hosting company that supports asp.net 2.0?

asp on linux

control array

ispostback and viewstate not initialized in composite control

datagrid post back problem when embedded in custom control

problem with user control!

dedicated asp.net hosting question

dynamic load style

click events in custom control

need an (scandinavien) alternative to aspnix

??? is inaccessible due to its protection level.

retreive values from user control in a code behind page

composite controls

designtime and dynamic propertys

client side controls

get the toolboxdata ...

loadcontrol function problem

go daddy and mail relay problem

send email with godaddy??

problem with datagrid checkbox column checkedchange event

custom control class name?

accessing a user-control's properties from within another

recommendations on windows hosting

render not updated

property browser in vs with custom control

value in designer not in sync at runtime

newbie: control help with calender

transferring domains

nesting user controls with codebehind (jscript.net)

common header and footer

calendar control, how to modify the day mon, tue etc.. display

the dynamic usercontrol and webpart paradox...

creating an iframe

please help with double buffering

custome controls, javascript, and firefox/mozilla

how do i use an embedded resource image in an imagebutton control in a custom server control?

composite control exposing a child control's datasource

how? have thmeable url's in custom control.

new httpresponse class, please help

wizard control .net framewrok 1.1

how to run a function inside usercontrol within codebehind of a aspx file

deriving a control from a base class declared mustinherit

how to start/stop smtp service from code?

need help very badly

datetimepicker user control

adding extra functionality to validators

retain viewstate for linkbutton control

problem with the active-x(ocx) control--it's urgent

problem with panels inside usercontrols

   
  Privacy | Contact Us
All Times Are GMT