Outputting textbox.text into html table

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
IanUoY
Posts: 88
Joined: Wed Jul 31, 2013 2:09 am

Outputting textbox.text into html table

Post by IanUoY »

Hi there
My form emails information to end users, and I format it as html and use the BodyAsHTML parameter.

For all intents and purposes this works fine. However, my problem arises when I want to include textbox.text within a table. If I save to a variable first and include that, works fine. If I just reference textbox.text, it doesn't.
How do I prevent the extra step?
eg:
$emailBody = $emailBody + "<span style=font-size:10pt><table><tr><td width=100><b>Username:</b></td><td width=750>$username</td></tr></table></style>" ....would work fine
$emailBody = $emailBody + "<span style=font-size:10pt><table><tr><td width=100><b>Username:</b></td><td width=750>$textboxUsername.Text</td></tr></table></style>" ...won't
Regards
Ian

User avatar
Alexander Riedel
Posts: 7522
Joined: Tue May 29, 2007 4:43 pm
Answers: 1
Been upvoted: 2 times

Re: Outputting textbox.text into html table

Post by Alexander Riedel »

[Topic moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.

jvierra
Posts: 14614
Joined: Tue May 22, 2007 9:57 am
Answers: 2
Has voted: 1 time
Been upvoted: 3 times
Contact:

Re: Outputting textbox.text into html table

Post by jvierra »

Fundamental to PowerShell. objects property references (the dotted reference $textbox.text) requier the use of subexpression expansion in a quoted string.

$emailBody += "<span style=font-size:10pt><table><tr><td width=100><b>Username:</b></td><td width=750>$($textboxUsername.Text)</td></tr>"

User avatar
IanUoY
Posts: 88
Joined: Wed Jul 31, 2013 2:09 am

Re: Outputting textbox.text into html table

Post by IanUoY »

Perfect...thank you :)

Locked