473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Asp.net User Control or Custom control Property doesnt accept inlineasp.net constract <%= %> is there a workaround?

Hi , I have got problem with passing my inline based value to y user
control (or custom control, no matter which one I use, I have tried
both to make sure it doesnt matter) .
So say I have property called ImagePath and i want to pass my value
through asp.net specific inline cunstruction:
<uc:MyControl runat=server id="someId" ImagePath="<%=
Request.ApplicationPath %>/App_Themes/<%= Page.Theme %>/Images/
ball_.png" />,

problem that in my property I get value exactly word for word:<%=
Request.ApplicationPath %>/App_Themes/<%= Page.Theme %>/Images/
ball_.png , but i Should get it like:
/WebSiteRoot/App_Themes/Green/Images/ball_.png.

For example if I use simple img html tag i works:
<img src="<%= Request.ApplicationPath %>/App_Themes/<%= Page.Theme %>/
Images/ball_.png" />
But if i add runat=server it brokes and i dont see any image coz the
path of image already messy string with <%= and so on.

I tried a lot of attributes to my ImagePath that found in web posts to
let it work (i.e.: [Bindable(true)],[Category("Data")],
[Browsable(true)] and many more) but no result.

Please let me know if you can resolve this interesting trick somehow?
Aug 25 '08 #1
3 1662
I was taught to troubleshoot using isolation: test one thing at a time.

So isolate your expressions you are attempting to bind to the page. I also
bring to your attention the use of the root path operator (~) so useful to
resolve paths. I would then isolate the use of Request.ApplicationPath and
get that part of your path correct.

Some parts of your path would look like "~/Images/ball_.png" for example and
I don't even think App_Theme is known to anything but the compiler but I
could be wrong about that as I don't think we can bind the Theme to the page
using an expression which may be why using Server controls vs HTML controls
appears to produce results.

"AleXmanFree" <al*********@gmail.comwrote in message
news:74**********************************@z72g2000 hsb.googlegroups.com...
Hi , I have got problem with passing my inline based value to y user
control (or custom control, no matter which one I use, I have tried
both to make sure it doesnt matter) .
So say I have property called ImagePath and i want to pass my value
through asp.net specific inline cunstruction:
<uc:MyControl runat=server id="someId" ImagePath="<%=
Request.ApplicationPath %>/App_Themes/<%= Page.Theme %>/Images/
ball_.png" />,

problem that in my property I get value exactly word for word:<%=
Request.ApplicationPath %>/App_Themes/<%= Page.Theme %>/Images/
ball_.png , but i Should get it like:
/WebSiteRoot/App_Themes/Green/Images/ball_.png.

For example if I use simple img html tag i works:
<img src="<%= Request.ApplicationPath %>/App_Themes/<%= Page.Theme %>/
Images/ball_.png" />
But if i add runat=server it brokes and i dont see any image coz the
path of image already messy string with <%= and so on.

I tried a lot of attributes to my ImagePath that found in web posts to
let it work (i.e.: [Bindable(true)],[Category("Data")],
[Browsable(true)] and many more) but no result.

Please let me know if you can resolve this interesting trick somehow?
Aug 25 '08 #2
Finally I found a good solution for this case.
Here is very good post of Dave Reed:
http://weblogs.asp.net/infinitiesloo...onBuilder.aspx
The short steps to achieve similar result are:

1) Create a class which inherits ExpressionBuilder:

using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom;
using System.Web.Compilation;
using System.Web.UI;

namespace Helper.Configurators
{
[ExpressionPrefix("InlineCode")]
public class CodeExpressionBuilder : ExpressionBuilder
{
public override CodeExpression GetCodeExpression(BoundPropertyEntry
entry, object parsedData, ExpressionBuilderContext context)
{
return new CodeSnippetExpression(entry.Expression);
}
}
}

2) register the newly created class in Web.Config:

<expressionBuilders>
<add expressionPrefix="InlineCode"
type="Helper.Configurators.CodeExpressionBuilder"/>
</expressionBuilders>

(it must be putted inside <configuration>)

3) and us it:

CategoryImage='<%$ InlineCode: Request.ApplicationPath+ "/App_Themes/"
+Page.Theme+ "/Images/ball_.png" %>'
Enjoy.
Aug 27 '08 #3
I really appreciate your commitment to come back to put this news article
into perspective. I needed more insight into the use of the
ExpressionBuilder class myself. Thanks again...

"AleXmanFree" <al*********@gmail.comwrote in message
news:af**********************************@i76g2000 hsf.googlegroups.com...
Finally I found a good solution for this case.
Here is very good post of Dave Reed:
http://weblogs.asp.net/infinitiesloo...onBuilder.aspx
The short steps to achieve similar result are:

1) Create a class which inherits ExpressionBuilder:

using System;
using System.Collections.Generic;
using System.Text;
using System.CodeDom;
using System.Web.Compilation;
using System.Web.UI;

namespace Helper.Configurators
{
[ExpressionPrefix("InlineCode")]
public class CodeExpressionBuilder : ExpressionBuilder
{
public override CodeExpression GetCodeExpression(BoundPropertyEntry
entry, object parsedData, ExpressionBuilderContext context)
{
return new CodeSnippetExpression(entry.Expression);
}
}
}

2) register the newly created class in Web.Config:

<expressionBuilders>
<add expressionPrefix="InlineCode"
type="Helper.Configurators.CodeExpressionBuilder"/>
</expressionBuilders>

(it must be putted inside <configuration>)

3) and us it:

CategoryImage='<%$ InlineCode: Request.ApplicationPath+ "/App_Themes/"
+Page.Theme+ "/Images/ball_.png" %>'
Enjoy.
Oct 9 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Versteijn | last post by:
Hello all I am developing a CountrySelector control (which I would like to share with anyone), but I am quite a newby in this custom control area. You can find it at:...
13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
10
by: BBM | last post by:
Hi, I have been developing with C# User Controls and occasionally have a problem where I "lose" a control from the design surface of the User Control. The controls that I am using to build my...
0
by: Versteijn | last post by:
Hello all I am developing a CountrySelector control (which I would like to share with anyone), but I am quite a newby in this custom control area. You can find it at:...
1
by: Jonathan Wood | last post by:
Okay, as evidenced by other questions, I am an experienced programmer very new to ASP.NET. I have a vertical navigation bar. It is all one color with several panels inside it with a different...
2
by: Josh Wolf | last post by:
The naming conventions that .NET uses in its HTML controls are driving me crazy! Pulling one in from a control or within a master page, for example, causes .NET to add class info to the "name"...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
4
by: Mike | last post by:
Hi all, In my recent ASP.NET 2.0 appl, I need to verify that the supplied email address is valid or not. So, here's my situation: - In my <profilearea, I created <isVerifiedproperty. - Suppose a...
1
by: AleXmanFree | last post by:
Hi , I have got problem with passing my inline based value to y user control (or custom control, no matter which one I use, I have tried both to make sure it doesnt matter) . So say I have...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.