cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

How to add variables and label.text to an htmltext control.

Similar to a label, I wish to use some of my powerapps variables in my HtmlText controls.  Its easy in a label to start and end with "&".   For instance.

 

"Label value = "&Label.text&" kg"

How can I do this in an HtmlText control?

1 ACCEPTED SOLUTION

Accepted Solutions
TimRohr
Level 10

Re: How to add variables and label.text to an htmltext control.

Perhaps I'm not understanding, but this works for me:

 

Button1.OnSelect=UpdateContext({myVar: "Some Text"})

 

HTMLText1.Text = "<p style='margin:0;
transform: rotate(-45deg);position: relative;'>" & myVar & "</p>"

 

That produces the following:

htmltext.PNG

Is that not the effect you're going for?

4 REPLIES 4
TimRohr
Level 10

Re: How to add variables and label.text to an htmltext control.

Sorry if this aims beneath your knowledge, but the & is a concatenation operator, putting pieces of text (strings) together. Text between quotation marks is already treated as literal string, while text outside of quotation marks is interpreted by the compiler. If that interpretation returns a string (like looking up a variable with text), then you would use an & to tie them together. For instance, if you established a variable:

UpdateContext({myString: "This is not."})

...and then put the following in the Text property of a control:

"This is actual text. " & myString

You would see the result:

This is actual text. This is not.

 

That works for an HTML Text control, too. For an HTML Text control, your final string construction is parsed to apply the HTML tags properly. But you can just put the HTML in either the literal text or a variable.

Super User
Super User

Re: How to add variables and label.text to an htmltext control.

@TimRohr,

 

Thank you for your reply.

 

Yes, that works if your text is to be completely outside of the HTML formatting.  However, in my case, I need the HTML formatting code to also apply to the PA variable.  

 

My case:

 

"<p style='margin:0;
transform: rotate(-45deg);position: relative;'>
Enter Date
</p>
"

 

In my case, myString needs to replace "Enter Date" within the formatting code above.  Otherwise, the text will not be at 45 degree angle, which is the point of the use of the HTML label to begin with.

 

Thank you.

TimRohr
Level 10

Re: How to add variables and label.text to an htmltext control.

Perhaps I'm not understanding, but this works for me:

 

Button1.OnSelect=UpdateContext({myVar: "Some Text"})

 

HTMLText1.Text = "<p style='margin:0;
transform: rotate(-45deg);position: relative;'>" & myVar & "</p>"

 

That produces the following:

htmltext.PNG

Is that not the effect you're going for?

Super User
Super User

Re: How to add variables and label.text to an htmltext control.

Ok, Sorry.  I'm old and slow.  That is what I'm after.

 

Thank you!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 40 members 4,379 guests
Please welcome our newest community members: