ASPX templates
Version 6.x > ASPX templates > Passing a Transformation field into a control property within a Transformation View modes: 
User avatar
Member
Member
whiplash - 10/19/2012 6:41:49 AM
   
Passing a Transformation field into a control property within a Transformation
Hi Guys

Does anyone know how to pass a value into a controls property within a Transformation?

I have a CMSWebParts/Maps/Static/StaticGoogleMaps.ascx within a transformation and want to pass data values into some of its properties ...
<%# Eval("OfficeLat",true) %>

<%# Eval("OfficeLon",true) %>

I have tried the following, escaping the double quotes with single quotes but it doesn't like it.

It does have access to these values, as I rendered them via the repeater to verify it.
Latitude='<%# Eval("OfficeLat",true) %>'
Longitude='<%# Eval("OfficeLon",true) %>'

I have a different solution in place but it does a full page postback which is not ideal, I want to try make the control get its data via the transformation now instead, then I can just show/hide it as needed.

Any help or guidance would be much appreciated

Regards

User avatar
Member
Member
whiplash - 10/19/2012 9:12:01 AM
   
RE:Passing a Transformation field into a control property within a Transformation
For anyone who may be interested ...

I solved this by wrapping the Eval in a Convert.ToDouble(......)

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/20/2012 3:10:36 PM
   
RE:Passing a Transformation field into a control property within a Transformation
Hi,

I'm really glad that you've found this simple solution by yourself!

This is caused because if you open site\CMSWebParts\Maps\Static\StaticGoogleMaps.ascx.cs file, there you will find under Location properties region that the definition of these properties is:
public double Latitude

public double Longitude

This is the reason why it's necessary to process these parameters as Double format.

So Convert.ToDouble(Eval("OfficeLat",true)) does the job.

Best regards,
Martin Danko