Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Custom attributes/properties at design time (serialization?)

Reply
Thread Tools

Custom attributes/properties at design time (serialization?)

 
 
WALDO
Guest
Posts: n/a
 
      08-15-2004
OK. here's what I want to do.

I have a text editor control that I created. I also have a seriedsof
palette controls that I have created for use with the text editor. The
Idea I want is that the page developer can slap any number of editors
on a webform and any number of palettes on the same webform and
associate an editor with a palette.

So all the editor really needs to know when rendering is the uniqueid
of the selected palette. What I have done is created a property of
type palette on the editor. I have created a typeconverter to grab all
the ids of the palettes on the webform. I have also set the
DesignerSerializationVisibility attribute to Visible and the
PersistenceMode to Attribute. Ultimately what I want to see is this:

<cc1:TextEditor runat="server" id="TextEditor1" Height="200px"
Width="500px" Palette="WebSafePalette1">This is my
InnerContent</cc1:TextEditor>

<cc1:WebSafePalette runat="server"
id="WebSafePalette1"></cc1:WebSafePalette>
<cc1:MSWordPalette runat="server"
id="MSWordPalette1"></cc1:MSWordPalette>
<cc1:StandardPalette runat="server"
id="StandardPalette1"></cc1:StandardPalette>

I want the Id of the selected palette to persist as an attribute
property in the HTML at design-time.

I see the list of palettes in the Palette property of the texteditor.
My problem is that when I set the DesignerSerializationVisibility
attribute to anything other than hidden, I get the error 'Invalid
property value (Object not set to an instance of an object)' whenever
I set the property at design time. When it is set to hidden, I don't
get the error. Unfortunately nothing persists to the texteditor or the
webform.

Any ideas as to how I may accomplish this? I thought maybe my
TypeEditor was wrong. Do I need a custom parser to fish out the
properties? Maybe a custom serializer to put the attribute property
where I want it. Maybe the serializer should put some code in the
InitializeComponent of the webform.
 
Reply With Quote
 
 
 
 
WALDO
Guest
Posts: n/a
 
      08-16-2004
OK. So I figured out my problem partially. It was my typeconverter. I
was assuming that in my ConvertTo function, context and
context.instance would always produce values and therefore was only
converting if they did. It's kind of funny, actually. I always thought
that I would throw some kind of exception if I DIDN'T check those
values. That's irony for you.

So I got the name of the control to persist to my attribute the way I
want. My new problem is how to DEserialize it. When I view the webform
in the browser, it produces the exception:

Unable to generate code for a value of type 'TextEdit.Palette'. This
error occurred while trying to generate the property value for
Palette.

I suppose I understand this. It's trying to generate a palette from
scratch from the value in the attribute, not the reference to the
object.

How would I approach DEserializing this object as a refernce to
another control on the webform?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Custom Control design time access to SQLConnection on Web Page Robin Shaw ASP .Net 1 08-12-2004 02:19 PM
error displaying custom control as design time Nikhil Patel ASP .Net 0 02-25-2004 03:22 PM
Design time rendering of a composite custom web control Barry Carr ASP .Net 4 01-15-2004 09:03 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com ASP .Net 0 07-01-2003 09:26 PM



Advertisments