RenderChildren/ParseChildren

G

Guest

I am having a slight problem. Below is something similar to what I want to
appear in the asp.net
<cc2:WebCustomControl1 id="WebCustomControl11" runat="server">

<FillList CommandName="asfsadf" ParameterName="sdafas" >

<ParameterNames>

<System.String Length="6">sdafas</System.String>

</ParameterNames>

</FillList>

</cc2:WebCustomControl1>

If it were up to me I would prefer to have something like
<cc2:WebCustomControl id="WebCustomControl1" runat="server">
<fillList CommandName="...." ParameterName="...">
<ParameterNames>
<Parameter name="@Retail"></Parameter
<Parameter name="@Detail"></Parameter
<Parameter name="@ISRepair"></Parameter
<ParameterName>

I have the first format working partially however the Designer breaks with
an error saying '' cannot be set on the property FillList and at runtime the
System.String is interpreted as an HtmlControl.

[

Bindable(true),

Category("SQL Properties"),

PersistenceMode(PersistenceMode.InnerProperty),

NotifyParentProperty(true),

DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]

public DataParameters FillList

{

get { return gFillList; }

set { gFillList = value; }

}



[TypeConverter(typeof(ExpandableObjectConverter)),

Browsable(true),

RefreshProperties(RefreshProperties.Repaint),

Serializable(),

ToolboxItem(false)]

public class DataParameters

{

[PersistenceMode(PersistenceMode.InnerProperty)]

public ArrayList ParameterNames

{

get { return gParameterNames; }

set { gParameterNames = value; SetParameterNames(value); }

}

}

Am I on the right track and there is just something that I am missing? or is
there a better way to do this. the MSDN Docs are pretty scarce on any
documentation/samples that go outside of a single simple nesting. Most of
what I have gleaned has been from various posts and has been extremly
incomplete.
 
M

marc.derider

Okay, I seem to have gotten around the problem of the controls being
interpreted as HtmlControls by adding a

<%@ Register TagPrefix="cc3" Namespace="System.Data.SqlClient"
Assembly="System.Data" %>

and then using this inside my
<Parameters>
<cc3:SqlParameter ParameterName="@Retail"></cc3:SqlParameter>
</Parameters>

Now is there a way to stop the designer from breaking with the error
message
'' could not be set on property 'FillList'.
And is there a way to get the ugly squiggly lines off of FillList and
Parameters
 
S

Steven Cheng[MSFT]

Hi Recoil,

Welcome to ASPNET newsgroup. From your description, you're develping a
custom webserver control which contains some nested propety elemetns which
are represented by some certain custom classes. However, you're
encountering some erros to get them work , yes?

Based on my research, for such scenarios, it's better to encapsulate your
FillList into another WebServerControl, then, you can make the
ParameterNames collection as a child property of the FillList control which
is like:

<cc2:WebCustomControl1 ....>
<cc2:FillList ...>
</cc2:FillList>
</cc2:WebCustomContrrol1>

Then, for FillList control, we can provide a custom ControlBuilder for it,
the control builder can help parse the nested content of the webcontrol and
determine which type it will be casted to. Also, there is a tech article
demonstrate on the similiar problem as yours(which make use of the custom
controlbuilder to parse our own properties) :

#ASP.NET Query control
http://www.codeproject.com/aspnet/MikEllASPNetQuery.asp

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
R

recoil

That however does not solve the issue where the Designer barfs by
stating 'Controlname' could not be set on property 'PropertyName' or ''
could not be set on property 'PropertyName'. It seems to only happen on
data structures that are nested and finding real world samples that use
lists inside of structures seem to be extremely non-existant. Just
postings about people with the same error and almost no solutions.
 
S

Steven Cheng[MSFT]

Hi Marc,

Thanks for your followup. yes, if there are more than one level nested
properties especially for ArrayList type, there'll have problems. So I
still suggest that we consider the following means:

1. Keep only one level nested List property such as :

<cc1:MyListControl runat="server">
<Items>
<MyItem name="name1" value="value1"></MyItem>
<MyItem name="name2" value="value2"></MyItem>
......
</Items>
</cc1:MyListControl runat="server">

This works ok , and we just need to set the ParseChildren(true) and define
the Items property for MyListControl control and another class named
"MyItem".


2. Set ParseChildren(false), then, we need to define our List's Items as
ASP.NET server control , also, if possbile, you can define a custom
ControlBuilder which may help us provide our own Parse logic.

Thanks,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
R

recoil

While I have half sorted the problem this works alot better in
theory/on paper then it does in real life. Both VS.NET 2003 and 2005's
support for this is extremely buggy. The Documentation for real world
examples that go beyond a single parameter are lacking. The
implementation is extremely difficult and mind boggling. For something
so simple why do so many different things need to be done and still
result in an extremely buggy result.
 
S

Steven Cheng[MSFT]

Thanks for your followup Recoil,

Yes, I can understand your concerns on the ParseChildren property , and
especially the MSDN document on this. The only sample is a simple control
with a nested ArrayList set as default property. Frankly speaking, I'm
also start testing from some other sample over the internet rather than
the MSDN's simple one. Also, I used to expect that I can have my control's
nested property elements the same as what we do in XmlSerialization but I
found I'm wrong. So I think we really need to start from improving our
documentation so as to ease the develpers' works.
Anyway, thank again for your posting and sorry for the inconvenience the
problem brings you.

Thanks & Regards,


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top