jQuery UI Widgets Forums Grid Escaping angle brackets

Tagged: , ,

This topic contains 5 replies, has 3 voices, and was last updated by  Gopre400 10 years, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Escaping angle brackets #53467

    Emanuel
    Participant

    Hello,

    trying to show text in a grid containing angle brackets results in hiding them as well as the text between them:

    Lorum epsum hello <friendly> world.

    results in

    Lorum epsum hello world. because it seems that <friendly> is added as a tag to the DOM. Escaping it on the server side doesn’t help.

    What’s the right way to escape it?

    Thanks in advance,
    Emanuel

    • This topic was modified 10 years, 3 months ago by  Emanuel.
    • This topic was modified 10 years, 3 months ago by  Emanuel.
    Escaping angle brackets #53473

    Peter Stoev
    Keymaster

    Hi Emanuel,

    As far as I know, the way to escape brackets is to encode them as: <code> instead of <code>

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Escaping angle brackets #54231

    Gopre400
    Participant

    Hi, I have a similar situation, left brackets “<” in text. How do I escape a data field in a grid?

    Escaping angle brackets #54239

    Peter Stoev
    Keymaster

    Hi Gopre400,

    Take a look at: http://stackoverflow.com/questions/10462348/right-angle-bracket-in-html

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Escaping angle brackets #54297

    Gopre400
    Participant

    Thank you Peter, I looked at the link you provided but it doesn’t really answer the question. It says you need to encode the characters which I have done doing this…

    Public Function GetSRQViewStreetPlatesGrid() As String
    Dim cmd As New SqlCommand()
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = “spSRQRequestsStreetPlatesOpen”
    Dim data As DataSet = GetSRQViewStreetPlatesData(cmd)
    Dim dr As DataRow
    Dim dt As DataTable
    dt = data.Tables(0)
    For Each dr In dt.Rows
    dr(“SignText”) = Uri.EscapeDataString(dr(“SignText”))
    Next
    Dim writer As New System.IO.StringWriter()
    dt.WriteXml(writer, XmlWriteMode.WriteSchema, False)
    Return writer.ToString()
    End Function

    But how do you decode the characters to display in a grid? I tried using the unescape function but does not work (data with < does not display).

    { text: ‘Text’, datafield: ‘SignText’, width: 200, editable: false, cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) {
    return unescape(rowdata.SignText);
    }
    },

    Escaping angle brackets #54298

    Gopre400
    Participant

    I got it to work…first remove the escape in the code behind…
    Public Function GetSRQViewStreetPlatesGrid() As String
    Dim cmd As New SqlCommand()
    cmd.CommandType = CommandType.StoredProcedure
    cmd.CommandText = “spSRQRequestsStreetPlatesOpen”
    Dim data As DataSet = GetSRQViewStreetPlatesData(cmd)
    Dim dt As DataTable
    dt = data.Tables(0)
    Dim writer As New System.IO.StringWriter()
    dt.WriteXml(writer, XmlWriteMode.WriteSchema, False)
    Return writer.ToString()
    End Function

    Then return cellsrenderer like this…
    { text: ‘Text’, datafield: ‘SignText’, width: 200, editable: false, cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) {
    return rowdata.SignText.replace(“<“, less than code).replace(“>”, greater than code);
    }
    },

    (because this is html I wrote out “less than code”)

    • This reply was modified 10 years, 2 months ago by  Gopre400.
    • This reply was modified 10 years, 2 months ago by  Gopre400.
    • This reply was modified 10 years, 2 months ago by  Gopre400.
    • This reply was modified 10 years, 2 months ago by  Gopre400.
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.