Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > tag = only property.get gets called

Reply
Thread Tools

tag = only property.get gets called

 
 
Sam
Guest
Posts: n/a
 
      07-26-2005
I've got:
<ParseChildren(True)> _
Public Class UserElement
Inherits WebControl

Public strLabel As new Label

Public Sub New()
strLabel.id = "myID"
End Sub

<PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property objLabel() As Label
Get
Return Me.strLabel
End Get
Set(ByVal value As Label)
me.strLabel = value
End Set

When calling:
<objLabel runat="server">mySecondLabel</objLabel>


I've noticed that only objLabel.set() gets called.
Which means the <objLabel> creates a "new" Label object.
So when the objLabel.set() gets called my old properties like ID (as set
in New()) get overwritten (with nothing, because not set in the tag).
Is there a way that ASP.NET first calles the objLabel.get() and then
"adds" the properties to this existing object?

The other option would be to copy all the properties by hand which is
quite ugly.


Sam.
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-28-2005
Hi,

not sure what you are trying to do besides exposing the Label but as the
Label is instantiated within the control, only get part of the property
makes sense. It returns a reference to the object and that reference can be
used to modify properties of the contained Label. therefore set part doesn't
make sense, because you don't want to reassign the reference, right?

E.g

<PersistenceMode(PersistenceMode.InnerProperty)> _
Public ReadOnly Property objLabel() As Label
Get
Return Me.strLabel
End Get
End Property

This is essentially what you mean by "Is there a way that ASP.NET first
calles the objLabel.get() and then
adds" the properties to this existing object?" as the returned reference is
only needed to modify the contained Label.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke



"Sam" <(E-Mail Removed)> wrote in message
news:42e6121f$0$20279$(E-Mail Removed).. .
> I've got:
> <ParseChildren(True)> _
> Public Class UserElement
> Inherits WebControl
>
> Public strLabel As new Label
>
> Public Sub New()
> strLabel.id = "myID"
> End Sub
>
> <PersistenceMode(PersistenceMode.InnerProperty)> _
> Public Property objLabel() As Label
> Get
> Return Me.strLabel
> End Get
> Set(ByVal value As Label)
> me.strLabel = value
> End Set
>
> When calling:
> <objLabel runat="server">mySecondLabel</objLabel>
>
>
> I've noticed that only objLabel.set() gets called.
> Which means the <objLabel> creates a "new" Label object.
> So when the objLabel.set() gets called my old properties like ID (as set
> in New()) get overwritten (with nothing, because not set in the tag).
> Is there a way that ASP.NET first calles the objLabel.get() and then
> "adds" the properties to this existing object?
>
> The other option would be to copy all the properties by hand which is
> quite ugly.
>
>
> Sam.



 
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
Return of gets gets John Joyce Ruby 0 04-23-2007 01:38 PM
gets gets John Joyce Ruby 2 03-26-2007 04:00 PM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM
only a simple xml reader <tag:id>value</tag:id> martijn@gamecreators.nl Python 4 02-11-2006 06:44 PM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM



Advertisments