[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

Using <% %> in a control's property gets converted to ascii codes

I've developed a site that has multiple colour schemes and as part of the scheme colour change I want to change the colour of the plus and minus buttons that I use on various CollapsiblePanelExtenders.

So being clever(?) i thought that if I made a public string to return the appropriate value i could call this into teh property using the <% Variable %> code markers, but when I do all that i get reurned is %3C%25=%20Variable%20%25%3E.

Below is the collapsible extender and the public string code that i'm using

<ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" CollapseControlID="imgButton" Collapsed="True" CollapsedImage="~/images/Schemes/<% LiveScheme %>/plus.PNG" ExpandControlID="imgButton" ExpandedImage="~/images/Schemes/<%= LiveScheme %>/plus.PNG" ImageControlID="imgButton" TargetControlID="Panel1"></ajaxToolkit:CollapsiblePanelExtender>

public string LiveScheme()
    {
           return "red";
    }

Any help greatly appreciated.
Steve
0
fusioninternet
Asked:
fusioninternet
  • 3
  • 3
1 Solution
 
rajvjaCommented:
Hi,

 why can't you do that from code behind by firing corr event procedure?
0
 
Steve KrileCommented:
My guess is you want the colors to change as the user interacts with the panel extender.  The approach you have above will not achieve that.  If you want to set these values on the server-side, then you could put that "business" in the OnPreRender event of the control.  That would allow you to inspect things on post back or when the page is drawn.
0
 
fusioninternetAuthor Commented:
Rajvja,

I don't think i can do this from codebehind because the CPE is within a repeater which generates a list of article titles that can be expanded by the user.

Steve
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fusioninternetAuthor Commented:
Skrile,

I have 3 sets of colour schemes set up which the user specifies from a control panel.
At the moment the expand/collapse buttons and scheme are red, but if the user has set the site so they use the blue scheme everything is blue apart from the expand and collapse buttons, therefore what i am trying to do is just get the expand/collapse buttons to load from a specific directory when they are generated. Just to throw a spanner in the works as stated above this extender is also within a repeater which is why i was trying to use the method above.


0
 
Steve KrileCommented:
Well, repeater or no, the OnPreRender event will do what you want.  


On your page:  


<ajaxToolkit:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" CollapseControlID="imgButton" Collapsed="True" ExpandControlID="imgButton"  ImageControlID="imgButton" TargetControlID="Panel1" OnPreRender="SetImageColor"></ajaxToolkit:CollapsiblePanelExtender>
   Private Sub CollapsiblePanelExtender1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles CollapsiblePanelExtender1.PreRender

         Dim cpe as CollapsiblePanelExtender = DirectCast(sender, CollapsiblePanelExtender)
         cpe.CollapsedImage="~/images/Schemes/" & LiveScheme & "/plus.PNG"
         cpe.ExpandedImage="~/images/Schemes/" & LiveScheme & "/plus.PNG"
   End Sub

Open in new window

0
 
fusioninternetAuthor Commented:
Cheers, it worked a treat.

I'm using C# rather than VB so below is the code I converted for anyone else interested.

 public void CollapsiblePanelExtender_PreRender1(object sender, System.EventArgs e)
    {
       
        CollapsiblePanelExtender cpe = (CollapsiblePanelExtender)sender;
        cpe.CollapsedImage ="~/images/Schemes/" & LiveScheme & "/minus.PNG";
        cpe.ExpandedImage = "~/images/Schemes/" & LiveScheme & "/plus.PNG"
    }
0
 
Steve KrileCommented:
Just noticed I put the following in the designer element:   OnPreRender="SetImageColor"

It should be :  OnPreRender="CollapsiblePanelExtender1_PreRender"
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now