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

radwindow problem with special charaters

3 Answers 208 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jessy Joseph
Top achievements
Rank 1
Jessy Joseph asked on 23 Jun 2011, 12:58 AM
When a user clicks on a hyperlink inside the grid it opens up a rad window, if the passing value has apostrophe ( ' ) in the text field, a js error is thrown. How to overcome this problem.

Thanks

Jessy

3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 23 Jun 2011, 11:35 AM
Hello Jessy,

If you are using apostrophes(') in your JavaScript code instead of double quotes (") to mark strings an apostrophe in the string would break your code. What you can do is use double quotes to delimit strings or try using the JavaScript escape() function for the said string, depending on your custom logic.

You can find attached a simple page that passes a value containing an apostrophe without issues. It does not obtain it from a grid, but I do not believe that this is relevant to the case.


Best wishes,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Jessy Joseph
Top achievements
Rank 1
answered on 23 Jun 2011, 05:31 PM
Marin,

I'm getting my values from the database. How should I resolve the problem?
 
in js
function UdateProductForm(productid,pname,rowindex) {
                                 
               window.radopen("UpdateProduct.aspx?RGSProductID=" + productid 
               +  "&RGSProductName=" + encodeURIComponent(pname), "rwRemoveGStatus");
               return false;
           }

In ServerSide
LinkButton linkProduct = (LinkButton)e.Item.FindControl("lkbtnProduct");
            linkProduct.Attributes["href"] = "#";
            linkProduct.Attributes["onclick"] = String.Format("return UdateProductForm('{0}','{1}','{2}');",
              e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ProductID"],
                e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ProductName"],
               e.Item.ItemIndex);
0
Marin Bratanov
Telerik team
answered on 24 Jun 2011, 12:05 PM
Hello Jessy,

I now see your issue. This happens because of the way strings are passed unencoded. In case your content has special characters you need to take care to properly encode your strings, as a special character could also break the query string.

I am attaching a simple project based on your code where I use one method to encode the strings. Please note that this is general knowledge and is the developer's responsibility to make sure the content will not break his application. That being said - the method I use is not the only one available and might not work in all scenarios, but is a starting point for a further research if you need another.


Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Window
Asked by
Jessy Joseph
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Jessy Joseph
Top achievements
Rank 1
Share this question
or