This is a migrated thread and some comments may be shown as answers.

How to display and get value in grid, where text has all special characters

3 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nirav
Top achievements
Rank 1
Nirav asked on 24 Jul 2014, 03:32 PM
Hi,
I am using VS 2013, Telerik.Web.UI Version 2014.2.618.45, developing a website using UI for ASP.Net AJAX telerik Q2 2014 controls. 
I have radgrid and binding columns to radgrid. 

Now, the problem is while binding and retrieving value of column containing special characters. 
Lets say one of the column has value as "Test &nbsp; test <br /> test ' test " test <asp:Label  Test \n test \\n test". 
I made this value to test. I want to display this in grid and also, I need to fetch this in two events, ItemDataBound and ItemCommand.
I tried various methods like HTMLEncoding, replacing characters and also tried putting label control inside ItemTemplate but could not retrieve value as it is.

So what I am looking for is, 
To display and retrieve data value "Test &nbsp; test <br /> test ' test " test <asp:Label  Test \n test \\n test" and "Test line 1 \r\n test line 2 \r\n" which is stored using multiline textbox. 
1. Is it possible to handle both scenario together? like handle straight string and also handle multiline textbox value to display and retrieve as entered. 
2. How to display above value in grid perfectly as it is? Consider both the cases, first, its string as it is and second, possible that its stored using multiline textbox
3. How to display above value in telerik:GridBoundColumn and in <asp:Label control inside <telerik:GridTemplateColumn? 
4. How to retrieve above value from grid as it is, in ItemDataBound and ItemCommand events?

Thanks in advance, 

















3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Jul 2014, 08:52 AM
Hello Nirav,

The issue that you are experiencing is a request validation feature of ASP.NET where, by default, the application is prevented from processing unencoded HTML content submitted to the server. Detailed information on this could be found at the following articles:
Since this is not related to our controls in any way, you will need to manually handle (encode/decode) the input and output in such manner, so you could pass the request validation or you could just disable it, but please note that this could lead to security issues.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Nirav
Top achievements
Rank 1
answered on 29 Jul 2014, 01:25 PM
Thanks for the reply, 
No problem. I thought Telerik might have some ways to handle special characters.
Its an web form with textboxes to enter values, I will see if it is good idea to restrict certain characters. 

Thanks,
0
Konstantin Dikov
Telerik team
answered on 29 Jul 2014, 03:00 PM
Hello Nirav,

I forgot to mention that GridBoundColumns have HtmlEncode property (set to false by default), which specifies whether the text in the corresponding cell will be encoded automatically or not when displayed in the browser. However, this only applies to the cells and you will not be able to edit those values, but if you only need to display the special characters you could set the HtmlEncode property to true and see how it works.

Detailed information on the above is available in the following help article:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Nirav
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Nirav
Top achievements
Rank 1
Share this question
or