+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Radupload and javascript

Radupload and javascript

4 posts, 0 answered
  1. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    30 Apr 2010
    Link to this post

    I am having problem to find a control in javascript. In the javascript code, I have


    var upload = $find('<%= RadUpload1.ClientID %>');


    And the following is how I set up the radupload.

    <telerik:RadUpload id="RadUpload1" OverwriteExistingFiles="False" ControlObjectsVisibility="ClearButtons" TargetFolder="~/MyFolder/" Runat="server" __designer:wfdid="w3"></telerik:RadUpload>

    <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="validateRadUpload" ErrorMessage="Please select at least one file" ></asp:CustomValidator>


    When I ran the page, I received the following error message: The name 'RadUpload1' does not exist in the current context. Any idea why?

    Thanks,
    Pik
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 May 2010
    Link to this post
    Hi Pik Lee,

    Most probably you are referring the RadUpload1 in the code behind of your control ( or class) otherwise you will get js error pop up. Most probably you have wrapped RadUpload1 in another control which means that you cannot call it directly, first you have to find it. Another possible reason could be some missing/wrong reference.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Pik Lee
    Pik Lee avatar
    142 posts
    Registered:
    13 Aug 2012
    11 May 2010
    Link to this post

    I have a FormTemplate inside the ascx file like below. I am having problem to use javascript to refer the control in the FormTemplate. Can someone assist me on how to use javascript to refer the control inside FormTemplate.

    Thanks, Pik

    <

     

    mastertableview datakeynames="msg_id" datasourceid="SqlDataSource1" commanditemdisplay="Top"><Columns>

     

    . . . . .

     

    <

     

    EditFormSettings EditFormType="Template">

     

    <

     

    EditColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1"></EditColumn>

     

    <

     

    FormTemplate>

     

    <

     

    telerik:RadUpload id="RadUpload1" runat="server" Width="347px" __designer:wfdid="w5" InitialFileInputsCount="1" TargetFolder="~/MyFolder/" ControlObjectsVisibility="ClearButtons" OverwriteExistingFiles="False"></telerik:RadUpload>

     

    <

     

    asp:button id="ButtonCancel" runat="server" __designer:wfdid="w10" text="Cancel" commandname="Cancel"></asp:button>

     

     

     

    </FormTemplate>
    </EditFormSettings>

     

    </

     

    mastertableview>

     

     

     

     

     

    </

    telerik:RadGrid>

     

    <

     

    script type="text/javascript">

     

    function

     

    onClientSubmitting(progressManager, args)

     

    {

     

    var eventTarget = document.getElementById('__EVENTTARGET');

     

     

    if (eventTarget.value == '<%= ButtonCancel.UniqueID %>' ||

     

    eventTarget.value ==

    '<%= btnUpdate.UniqueID %>')

     

    {

     

    //Clear the file inputs

     

     

     

     

     

     

    var upload = $find("<%= RadUpload1.ClientID %>");

     

     

    var fileInputs = upload.getFileInputs();

     

     

    for (var i=0; i<fileInputs.length; i++)

     

    {

    upload.clearFileInputAt(i);

    }

    }

    }

     

     

     

    </

     

    script>

     

     

     

     

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    12 May 2010
    Link to this post
    Hi Pik Lee,

    The problem is that your RadUpload is nested withing another control. This way you can 1) either put a hidden field on your page and on ItemDataBound server event pass the client id of the RadUpload control as value of the hidden field. Probably not applicable in your case.

    2) Instead of having an inline template you can create a modal pop-up for the edit template and put the RadUpload in the markup of the modal popup page. This way the RadUpload1.ClientID can be used. A sample can be found here.

    3) The third option would be to make your custom control inherit from IScriptControl, then on edit of the control you will be able to pass the ClientId of the RadUpload and use it. Sample script control can be found here.

    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
4 posts, 0 answered