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

Controls in Rad Window not on page source

4 Answers 46 Views
Window
This is a migrated thread and some comments may be shown as answers.
Abram
Top achievements
Rank 1
Abram asked on 24 Feb 2009, 09:11 PM
Hi, I have Radwindow with a RadGrid inside. I have a RadUpload in one of the columns of the grid and am trying to persist the value of the file selected by storing it in a hidden field on the OnClientFileSelected event of the Upload.

My javascript to do this

function SaveUploadFile(radUpload, eventArgs)
        {
                var obj = document.getElementById("hidden_field_id");
                obj.value = radUpload._fileInput.value;
        }

Now the getElementById is returning null when the OnClientFileSelected event fires. I have looked for a while for a solution and am wondering if it has to do with the fact that nothing in the Rad Window shows on the page source of the page. Would this prevent the javascript function from being able to find my hidden field id?

Thanks,
Abram

4 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 26 Feb 2009, 07:38 AM
Hi Abram,

I am not quite sure where you have placed the HiddenField control. If this element is on the parent page, you can access it by using the following functions on the content page of the RadWindow :

<script language="javascript" type="text/javascript"
    function SaveUploadFile(radUpload, eventArgs) 
    { 
        var parentDocument = GetRadWindow().BrowserWindow.document
        var obj = parentDocument.getElementById("hidden_field_id"); 
        obj.value = radUpload._fileInput.value; 
    } 
 
    function GetRadWindow() 
    { 
        var oWindow = null
        if (window.radWindow) 
            oWindow = window.radWindow; 
        else if (window.frameElement.radWindow) 
            oWindow = window.frameElement.radWindow; 
        return oWindow; 
    } 
</script> 

Other possible reason for the null value could be if you use the INAMING container ( like MasterPage ). In this case you should use the $find() function instead getElementById() and the ClientID property of the server control e.g :

function SaveUploadFile(radUpload, eventArgs) 
    var obj = $find("<% hidden_field_id.ClientID %>"); 
    obj.value = radUpload._fileInput.value; 

Please note that in this case you should wrap the SaveUploadFile() function with RadCodeBlock. This is necessary  because of used server parenthesis (<% %>).

In case your scenario is different than described above, could you please provide more information about your exact setup? It is best to open a new support ticket and send us a simple demo project that reproduces the problem. Once we have a better view over your setup, we will do our best for help.

Regards,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Abram
Top achievements
Rank 1
answered on 26 Feb 2009, 07:31 PM
No the hidden field is not on the parent page. I am actually placing the hidden field inside the gridview column along with the file upload. That way if I were to update more than one row at a time and select two different files, I could have two hidden fields to store two different paths to a file, since they would be generated once per row in edit mode.

I don't know if it is possible to use javascript to get the ids because I don't see anything in the page source that would be a grid or the controls inside of it.

I thought the RadUpload should persist the path and I wouldn't have to use a hidden field, but it doesn't seem to persist the file path when I click the upload button. (I have a button in there as well)

The hidden filed and the grid contents are all generated in the vb file server code. I can't reference my ID in the aspx page.

It will be complicated to send you a demo stripped down version so if its at all possible to help diagnose the problem this way please do.

Thanks,
Abram
0
Fiko
Telerik team
answered on 27 Feb 2009, 03:15 PM
Hello again,

I am afraid that the information that you provided is not enough for us and we cannot locate the exact reason for the problem. Could you please open a new support ticket and send us the simple code snippets where we can observe your setup?

Kind regards,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Abram
Top achievements
Rank 1
answered on 27 Feb 2009, 06:15 PM
We are implementing a new approach that I think will work, but thank you anyway. Also, any code snippets would be far from simple. :)
Tags
Window
Asked by
Abram
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Abram
Top achievements
Rank 1
Share this question
or