Home All Groups Group Topic Archive Search About
Author
30 Jul 2006 10:15 PM
paul.hester
Hi all,

I have a custom control with an overridden Render method. Inside this
method I'm rendering each control in its collection using their
RenderControl method. However, I'm running into a problem in this
scenario:

<myprefix:mycontrol runat="server">
        <%= SomeVariable %>
</myprefix:mycontrol>

The contained control is showing up in the control collection as a
LiteralControl, but its Text property is empty. Well, it's a series of
spaces, so it's not showing up with any content. I can put <%=
SomeVariable %> anywhere outside my custom control and it will render
the variable value correctly.

Is there anything I can do to ensure the variable value is rendered?

I hope this post makes sense!

Thanks,

Paul

Author
31 Jul 2006 1:51 PM
Alessandro Zifiglio
hi Paul, it is my thinking that the expression is already written out to the
output stream, and that the evaluation of the expression is not deposited in
the containing .aspx page at a suitable time for usage by your control and
as such cannot make much use of it.
Reference msdn online about this particular inline code construct here :
http://msdn2.microsoft.com/en-us/library/6dwsdcf5.aspx

If you want to simply support adding text in btw your controls tags or
support nesting of child elements, then you want to make a new class that
inherits the ControlBuilder and associate your custom control with this.
Here is an example of how to use the ControlBuilder :
http://msdn2.microsoft.com/en-us/library/system.web.ui.controlbuilder.aspx

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

<paul.hes***@gmail.com> ha scritto nel messaggio
Show quoteHide quote
news:1154297710.332815.129610@s13g2000cwa.googlegroups.com...
> Hi all,
>
> I have a custom control with an overridden Render method. Inside this
> method I'm rendering each control in its collection using their
> RenderControl method. However, I'm running into a problem in this
> scenario:
>
> <myprefix:mycontrol runat="server">
>        <%= SomeVariable %>
> </myprefix:mycontrol>
>
> The contained control is showing up in the control collection as a
> LiteralControl, but its Text property is empty. Well, it's a series of
> spaces, so it's not showing up with any content. I can put <%=
> SomeVariable %> anywhere outside my custom control and it will render
> the variable value correctly.
>
> Is there anything I can do to ensure the variable value is rendered?
>
> I hope this post makes sense!
>
> Thanks,
>
> Paul
>
Author
2 Aug 2006 9:32 AM
Alessandro Zifiglio
Auto-Correction :
You are unable to get the value of the inline codeblocks expression syntax
<%= %> since the default ControlBuilder does not pass back anything.
Instead, on the other hand, the built in ControlBuilder has support for
databinding expression syntax<%# %> allowing you to retrieve this value. It
makes the value available as a DataBoundLiteralControl. Note that to get the
value, it needs to added to your controls, control collection first, and
then reference the control in the collection in a phase after the
DataBinding phase in your controls life cycle.

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

Show quoteHide quote
"Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha scritto
nel messaggio news:uiO%232hKtGHA.372@TK2MSFTNGP06.phx.gbl...
> hi Paul, it is my thinking that the expression is already written out to
> the output stream, and that the evaluation of the expression is not
> deposited in the containing .aspx page at a suitable time for usage by
> your control and as such cannot make much use of it.
> Reference msdn online about this particular inline code construct here :
> http://msdn2.microsoft.com/en-us/library/6dwsdcf5.aspx
>
> If you want to simply support adding text in btw your controls tags or
> support nesting of child elements, then you want to make a new class that
> inherits the ControlBuilder and associate your custom control with this.
> Here is an example of how to use the ControlBuilder :
> http://msdn2.microsoft.com/en-us/library/system.web.ui.controlbuilder.aspx
>
> Regards,
> Alessandro Zifiglio
> http://www.AsyncUI.net
>
> <paul.hes***@gmail.com> ha scritto nel messaggio
> news:1154297710.332815.129610@s13g2000cwa.googlegroups.com...
>> Hi all,
>>
>> I have a custom control with an overridden Render method. Inside this
>> method I'm rendering each control in its collection using their
>> RenderControl method. However, I'm running into a problem in this
>> scenario:
>>
>> <myprefix:mycontrol runat="server">
>>        <%= SomeVariable %>
>> </myprefix:mycontrol>
>>
>> The contained control is showing up in the control collection as a
>> LiteralControl, but its Text property is empty. Well, it's a series of
>> spaces, so it's not showing up with any content. I can put <%=
>> SomeVariable %> anywhere outside my custom control and it will render
>> the variable value correctly.
>>
>> Is there anything I can do to ensure the variable value is rendered?
>>
>> I hope this post makes sense!
>>
>> Thanks,
>>
>> Paul
>>
>
>