Re: Strange Custom Control Problem (.Net 2.0)
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Thu, 10 Jan 2008 02:11:32 GMT
Thanks for your reply Tomasz,
Yes, I agree that Binding Expression is not quite convenient for value
assignment cases. I think that's why "code expression bulder" is added in
ASP.NET 2.0 which is quite flexible and powerful :)
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: "Tomasz J" <oegweb@xxxxxxxxxxxxx><spXdCfpUIHA.4720@xxxxxxxxxxxxxxxxxxxxxx>
References: <#an5P0lUIHA.4768@xxxxxxxxxxxxxxxxxxxx>
Subject: Re: Strange Custom Control Problem (.Net 2.0)that
Date: Wed, 9 Jan 2008 16:30:32 +0100
Thank you Steven!
I was unaware of this limitation. This syntax worked with my ascx controls.
Good to know. Perhaps it is something which could be improved, because
binding is less convenient.
Tomasz J
"Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:spXdCfpUIHA.4720@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Tomasz,
As for the problem you met, it is due to the limitation of expression
onlycan be used inside ASP.NET server control attribute/tag. The <%= %>
expression is brought from classic ASP for compatible purpose and can
thebe used in plain html fragment(at top level of aspx page or ascx user
control).
For ASP.NET server control tag, you can consider the following means to
embed dynamic value:
1. Use <%# ... %> like databinding expression, however, you need to call
control.DataBind() at runtime (in page load or init ...) so as to make
http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBdatabinding expression get evaluated.
2. In ASP.NET 2.0, there provides a custom Expression Builder
functionality, that can help you define your own custom expression(can be
used inside server control tag/attributes). Here are some articles
introducing this:
#The CodeExpressionBuilder
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notifuilder.aspx
http://weblogs.asp.net/leftslipper/archive/2007/01.aspx
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
issuesications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent
followwhere an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
inup response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
From: "Tomasz J" <oegweb@xxxxxxxxxxxxx>
Subject: Strange Custom Control Problem (.Net 2.0)
Date: Wed, 9 Jan 2008 02:15:06 +0100
Control
Hello Developers,
I have a control derived from System.Web.UI.WebControls.WebControl.
has this property:
[Bindable(true), Category("Misc"), Description("value")]
public string Value
{
set { _value = value; }
get { return _value; }
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
writer.AddAttribute("alt", _value);
}
I use my control like this:
<mc:MyControl ID="MyControl" Value="<%=Value %>" runat="server" />
(the page class has protected Value property)
There are no compilation problems, but ASP.Net incorrectly renders alt
attribute:
alt="<%=Value %>"
It seems like it is a problem at compile-time. I cannot use expressions
control attribute values.
What could be wrong with this picture?
Any hints highly appreciated.
Tomasz J
.
- References:
- Strange Custom Control Problem (.Net 2.0)
- From: Tomasz J
- RE: Strange Custom Control Problem (.Net 2.0)
- From: Steven Cheng[MSFT]
- Re: Strange Custom Control Problem (.Net 2.0)
- From: Tomasz J
- Strange Custom Control Problem (.Net 2.0)
- Prev by Date: Re: Exception - Padding is Invalid
- Next by Date: RE: IIS bug-Concurrent request lock before IHttpModule.AcquireRequ
- Previous by thread: Re: Strange Custom Control Problem (.Net 2.0)
- Next by thread: Location of Shared Theme Items
- Index(es):
Relevant Pages
|