locked
Including HTML in text field RRS feed

  • Question

  • Hello,

    I am trying to display html in a text field on a screen in LightSwitch, can someone let me know if this is possible and if so how I do it?

    I have tried to use Elyl's Extension but to no avail.

    Thanks,

    Ken

    Tuesday, January 8, 2013 11:36 AM

Answers

  • Thanks Yann,

    I think that now that I have got my head around the fact that all controls need to be bound to a property I can go back to Elyl's HTMLViewer control and store the HTML formatted text in the database.

    Thanks for your assistance.

    Ken

    • Marked as answer by kenjonesepa Thursday, January 10, 2013 11:14 AM
    Thursday, January 10, 2013 11:13 AM

All replies

  • Were you looking to display it as HTML (i.e. displayed like a web page)?  Or did you have an issue with the escaping?

    I guess what I am asking is would this be editable or just displayed?


    Derek

    Tuesday, January 8, 2013 11:18 PM
  • Derek,

    Thanks for your response, I am just wanting to display the html to enable some text formatting and the inclusion of hyperlinks etc.

    Thanks,

    Ken

    Wednesday, January 9, 2013 9:07 AM
  • What problems did you have with my extension?

    If you just want to display HTML, change one of the textbox/label controls to an HTML Viewer control, and make sure the value it's displaying has some HTML in it.


    Free Visual Studio LightSwitch extensions: Elyl's Extensions

    Wednesday, January 9, 2013 10:10 AM
  • Hello ElyIV,

    Thanks for reading and responding!

    My issue was just that I didnt know which property to assign the html to to display it in the HTMLViewer control.

    Thanks,

    Ken



    • Edited by kenjonesepa Wednesday, January 9, 2013 10:19 AM typo
    Wednesday, January 9, 2013 10:19 AM
  • The HTML Viewer will take either a String or my own HTMLText business type.

    The control is meant to display HTML stored as a string in one of the columns of your database tables, so you'd drag the string onto your screen then change it to an HTML Viewer.

    The control's not really meant for displaying static HTML on the screen, but you could create a Local Property on you screen, and assign the value of it in the _InitializeDataWorkspace call for the screen.


    Free Visual Studio LightSwitch extensions: Elyl's Extensions

    Wednesday, January 9, 2013 2:11 PM
  • Ok, thanks for your reply.

    Do you have any suggestions as to how I could best achieve this? Do I have to separate all my text into different text blocks if they require different formatting?

    Wednesday, January 9, 2013 2:26 PM
  • My HTML Viewer control will display any HTML you set it to, so you could have multiple formats over a number of paragraphs.

    Can I ask what you're planning to do with the HTML?  I would only recommend using this control to display, for example, documentation or something like that.  If you just want to change the format of a standard textbox, or labels, I would recommend Pixata controls: http://visualstudiogallery.msdn.microsoft.com/9c342bec-e3e5-4c08-9993-35ccb26d3c9f, as those controls are more integrated into the interface itself rather than a block of HTML.


    Free Visual Studio LightSwitch extensions: Elyl's Extensions

    Wednesday, January 9, 2013 2:53 PM
  • I need to display a Terms & Conditions page which contains text in different formats and some hyperlinks.

    Seems a bit odd to me that there isnt a standard way to display this kind of information in an application as clever as LightSwitch.
    Wednesday, January 9, 2013 5:24 PM
  • I created a TextBlock control, which you'll find in my free Luminous Controls for LightSwitch extension, for exactly that purpose. But it wouldn't handle the hyperlinks, I just realised.

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, January 10, 2013 1:49 AM
    Moderator
  • Once again thanks Yann, if your TextBlock does what I need then I will manage and just add in a Hyperlink button for the hyperlinks.
    Thursday, January 10, 2013 9:29 AM
  • Quick question if you are reading this Yann.

    How do I populate the TextBlockControl with formatted text? Does it have to be bound to a property on an entity or do I add a screen property? 

    Apologies if this information is elsewhere or obvious, I am still learning about LS.

    Thanks for your help!

    Ken

    Thursday, January 10, 2013 10:41 AM
  • Funnily enough, the notification of your reply just popped up Outlook, lol.

    If you're looking for freeform formatting, my control won't do that. Yes, you do need to bind to a property (a screen property is fine), but the value of the actual property is ignored, being replaced with the text that you define at design time. In LightSwitch all controls have to be bound to a property. I wasn't able to find a way around that, hence the dummy property requirement.

    But you can share one screen property with as many TextBlock controls as you want, you don't need one property per control, as you would with a Label controls.

    It's a "themed" control, & you can only have one format per control however, which I suspect isn't what you want. the formats are derived from theme values (Heading1, Heading2 etc). You simply select it again at design time.

    By combining a GroupLayout control with several nested TextBlock controls (by adding a RowsLayout to the GroupLayout, then adding TextBlock controls to the RowsLayout control), you can come up with some pretty impressive layouts (see the examples on the extension's download page).


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, January 10, 2013 11:10 AM
    Moderator
  • Thanks Yann,

    I think that now that I have got my head around the fact that all controls need to be bound to a property I can go back to Elyl's HTMLViewer control and store the HTML formatted text in the database.

    Thanks for your assistance.

    Ken

    • Marked as answer by kenjonesepa Thursday, January 10, 2013 11:14 AM
    Thursday, January 10, 2013 11:13 AM
  • When using a TextBlock control, the value doesn't need to be stored in the database, it's static design-time text. But if the HTMLViewer control does what you need, & you can cope with storing the text in the database, then that's great.

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, January 10, 2013 11:17 AM
    Moderator