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

Using & and & with RadWindow

4 Answers 82 Views
Window
This is a migrated thread and some comments may be shown as answers.
Johan Olofsson
Top achievements
Rank 1
Johan Olofsson asked on 08 Aug 2008, 01:20 PM
(Edited:  the subject was meant to be using & and &)

Hi there.

Got some smaller problem which i hope i can get some help with.

I've got some problem with using & (the XHTML correct way) with RadWindows.

When i use a single & it works perfect getting the variables in the new window. But that's of course not the correct way when you want to have your site XHTML-validated.

When i try to use & instead i'm getting:
contentTemplate1Admin.aspx?SitId=1&PagID=1&ModId=46

instead of:
contentTemplate1Admin.aspx?SitId=1&PagID=1&ModId=46



I've tried to use a javascript function also:
link = link.replace(/&/g, "&");

but then the validator complains on that single "&" (of course).


Is there anything i can do to solve this problem?

Would be very thankful for any kind of help or guiding in this matter.

Kind Regards / Johan

4 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 12 Aug 2008, 08:07 AM
Hello Johan,

The problem comes from the way the browser handles setting an URL with & to an IFRAME (RadWindow is based on an IFRAME and it behaves like one). For your convenience I attached to this thread a small test that illustrates this behavior. There I have used the following string for testing:
"http://www.google.bg/search?num=100&hl=en&newwindow=1&safe=off&q=telerik+radcontrols&btnG=Search&meta="

As you will see, when this string is set directly in the IFRAME's declaration or is opened in a browser's popup, it opens the correct page in Google. This is not the case however, when the src attribute of the IFRAME is set with Javascript - e.g. what we basically do when opening the RadWindow with JavaScript.

Can you please provide more details about your exact setup? Where the validation fails and how exactly do you set the Url? If we have a better view over your scenario, we might be able to provide you with an appropriate workaround.


Best wishes,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Johan Olofsson
Top achievements
Rank 1
answered on 12 Aug 2008, 10:17 AM
Hi Georgi.

Thanks for the answer. I will try my best to give you a better picture of what my problem is.

I've got plenty for "admin" windows in my site which are open by your RadWindow product. This works wonders when i'm using this code for the link:

oWnd.SetUrl("Modules/content.aspx?SitId=" + SidId + "&PagID=" + PagId  + "&ModId=" + ModId);

But. When i'm trying to validate the site by w3-validator i'm getting errors for using ex. &PagID instead of &PagId.

I tried to change all my links from & to &. This made all the site fully validated. But instead i got problems with getting the Request-variables in the newly open windows because the new link wont encode the & to an &. The new window is getting the url:
"...Modules/content.aspx?SitId=1&PagID=1&ModId=3"


i will add some code examples for hopefully better understanding.
-----------------------------------------------------------------
<script type="text/javascript"
    var oLoadingWindow; 
         
    function openRadWindow(SidId,PagId,ModId,WINDOW,PagT) 
    {    
        var oManager = GetRadWindowManager(); 
        var oWnd = oManager.GetWindowByName(WINDOW); 
          
        if(WINDOW=='ADMIN_CONTENTTEMPLATE2'
        { 
            oWnd.SetUrl("Modules/content.aspx?SitId=" + SidId + "&PagID=" + PagId  + "&ModId=" + ModId); 
        } 
         
        oWnd.Show();  
    }   
 
</script> 



This code is working but isn't XHTML-valid.


Hope you have some better overview of my problem now.

Kind Regards / Johan




0
Accepted
Georgi Tunev
Telerik team
answered on 13 Aug 2008, 03:36 PM
Hello again Johan,

I checked your code in W3C validator, but I didn't get any errors regarding the ampersand - only a note for an entity which is not an actual error (see attached screenshot). I asked you where you get the error because in general JavaScript is not validated and you should not experience problems with it. Can you provide me with a screenshot of the validation error and the validation options that you have set in the validator's page?

If you still would like not to use & in your code however, I recommend to consider setting the Url from the codebehind.



Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Johan Olofsson
Top achievements
Rank 1
answered on 14 Aug 2008, 08:31 AM
Hi.

Thanks for the reply. That made me rethink a bit and i solved it with adding the javascript in the code behind which you suggested with some modifications.


Thanks for all help.!

/ Johan

Tags
Window
Asked by
Johan Olofsson
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Johan Olofsson
Top achievements
Rank 1
Share this question
or