Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Asp.net User Control or Custom control Property doesnt accept inlineasp.net constract <%= %> is there a workaround?

Reply
Thread Tools

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

 
 
AleXmanFree
Guest
Posts: n/a
 
      08-25-2008
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?
 
Reply With Quote
 
 
 
 
HillBilly
Guest
Posts: n/a
 
      08-25-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?


 
Reply With Quote
 
 
 
 
AleXmanFree
Guest
Posts: n/a
 
      08-27-2008
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.
 
Reply With Quote
 
Hillbilly
Guest
Posts: n/a
 
      10-09-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.


 
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
sort list doesnt work, key=str still doesnt work notnorwegian@yahoo.se Python 3 05-27-2008 04:32 AM
PC doesnt boot first time and doesnt shutdown dann Computer Support 6 08-21-2006 07:31 AM
feeding a SQLDataSource embedded in an .ascx user control a custom property assigned to that control ASP .Net 4 07-16-2006 12:20 PM
Keep custom property-value in custom rendered control Rob Joosen ASP .Net Building Controls 0 05-12-2004 11:56 AM
Accept properties in Property Box for Customr Validator /or any Custom Control Vinod I ASP .Net 1 02-26-2004 05:08 PM



Advertisments