Telerik Forums
UI for ASP.NET AJAX Forum
7 answers
239 views
Hello,

I'm trying to set a customvalidator for the RadUpload control in order to check the maximum upload size, but I got an error (Attached screen-shot). My code is based on http://sample.topscms.com/blog/post/1607--client-side-file-size-validation-for-telerik-upload.

Default2.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       <asp:ScriptManager ID="asdasD" runat="server">
       </asp:ScriptManager>
 
       <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                var currentLoadingPanel = null;
                var currentUpdatedControl = null;
 
                function RequestStart(sender, args) {
                    currentLoadingPanel = $find("<%= TasksRadAjaxLoadingPanel.ClientID %>");
 
                    if (args.get_eventTarget() == "<%= SubmitButton.UniqueID %>") {
                        args.set_enableAjax(false);
                    }
 
                    currentUpdatedControl = "<%= MainPanel.ClientID %>";
 
                    //show the loading panel over the updated control
                    currentLoadingPanel.show(currentUpdatedControl);
                }
 
                function ResponseEnd() {
                    //hide the loading panel and clean up the global variables
                    if (currentLoadingPanel != null)
                        currentLoadingPanel.hide(currentUpdatedControl);
                    currentUpdatedControl = null;
                    currentLoadingPanel = null;
                }
 
                function validateRadUploadFileSize(source, arguments) {
                    var totalFileSize = 0;
                    var maxFileSize = 100000;
                    var radUpload = $find('<%= AttachedFilesRadUpload.ClientID %>');
                    var fileInputs = radUpload.getFileInputs();
                    for (var i in fileInputs) {
                        if (fileInputs[i] && fileInputs[i].files[0]) {
                            totalFileSize += fileInputs[i].files[0].fileSize;
                        }
                    }
 
                    arguments.IsValid = totalFileSize <= maxFileSize;
 
                }
            </script>
        </telerik:RadCodeBlock>
 
 
       <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="SubmitButton">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="MainPanel" LoadingPanelID="TasksRadAjaxLoadingPanel" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
            <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />
        </telerik:RadAjaxManager>
 
        <telerik:RadAjaxLoadingPanel ID="TasksRadAjaxLoadingPanel" Skin="Vista" runat="server">
        </telerik:RadAjaxLoadingPanel>
 
        <asp:Panel ID="MainPanel" Width="100%" HorizontalAlign="Left" runat="server">
 
            <telerik:RadProgressManager ID="Radprogressmanager1" Width="403px" runat="server" />
            <telerik:RadUpload ID="AttachedFilesRadUpload" InitialFileInputsCount="1" MaxFileInputsCount="10" ControlObjectsVisibility="AddButton, RemoveButtons, CheckBoxes"
                       Width="405px" runat="server" />                       
            <telerik:RadProgressArea runat="server" Width="405px" ID="ProgressArea1" ></telerik:RadProgressArea>
 
             <asp:CustomValidator runat="server" ID="CustomValidator1" Display="Dynamic" ClientValidationFunction="validateRadUploadFileSize"
                        OnServerValidate="CustomValidator1_ServerValidate" ValidationGroup="CreateNewTaskValidationGroup">       
                        The maximum upload size is 100 KB
             </asp:CustomValidator>
 
             <asp:Button runat="server" ID="SubmitButton" ValidationGroup="CreateNewTaskValidationGroup" Text="Submit" />
 
         </asp:Panel>
 
    </div>
    </form>
</body>
</html>

Default2.aspx.cs:

using System;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = (AttachedFilesRadUpload.InvalidFiles.Count == 0);
}
}

Please, I need you help in order to solve this problem.
It is very appreciated to send me the modified code.

Regards,
Bader
Kevin
Top achievements
Rank 2
 answered on 01 Dec 2011
1 answer
516 views
We have found a Xss vulnerability in the Telerik.Web.UI.WebResource.axd [_TSM_CombinedScripts_ parameter], where it is possible to edit the javascript. We are currently using an older version of the library (2009.3.1103.20). Can anyone confirm that this issue is fixed in the latest release, and in what version was this issue solved?
Simon
Telerik team
 answered on 01 Dec 2011
7 answers
177 views
I'm not even sure this can be done, but here goes:

What I am trying to do is avoid database hits on every character entered in a Load-On-Demand RadComboBox.  When one character is entered, I go to the database and get the resulting dataset.  Any further characters entered will filter that same dataset.  The only time the database is accessed is when the first character is entered.  Is this even possible? If so, any pointers?
Ivana
Telerik team
 answered on 01 Dec 2011
4 answers
195 views
Hi Everone

Can some one tell me why i get this error
Microsoft JScript runtime error: Object doesn't support property or method 'get_items'

when i execute the following js code
var listbox = document.getElementById("<%=rlbCustomEmails.ClientID %>");
var item = new Telerik.Web.UI.RadListBoxItem();
item.set_text(email);
listbox.get_items().add(item); //I get the error here

it is searching for this control
<telerik:radlistbox runat="server" style="position: absolute; top: 290px; left: 400px;"
        height="240px" width="255px" ID="rlbCustomEmails"></telerik:radlistbox>

KobusVisagie
Top achievements
Rank 1
 answered on 01 Dec 2011
1 answer
59 views
Hi,

The look of grouping (in the data area of a grid) consists of three elements:
  • the group header
  • the cell to the left of the group header, containing icons for expanding / collapsing; let's name it "the control cell"
  • cells the the left of data rows; let's name them "filling cells"

I'm using the Simple skin and Q1 2010 version of the controls.
All these elements have initially the same, darkgray background. The control cell (and its column) is quite wide. I would like to change two aspects of their look:

  • the back color of all of them
  • the width of the control cell and the filling cells

I tried to use GroupHeaderItemStyle. Changing its BackColor changed the back color of the header and the filling cells - but the control cell remained untouched. Changing its Width changed nothing.
I tried to modify Grid.Simple.css file. I've succeeded in changing the back color of all the required elements. But I cannot make the column with the control and filling cells narrower. The MasterTableView is rendered with the "colgroup" element wich contains 20px width of this column. This is the key - is it possible to me to change this value?

Regards
Tomasz

Mira
Telerik team
 answered on 01 Dec 2011
2 answers
138 views
Hello.

I have a Grid with an EditMode="Popup". I would like to display a gif image (an animated wheel or anything else) while the popup window is loading (this takes around 1 or 2 seconds).

How can I do this?

Thanks for you help
Regards
Augusto
Augusto
Top achievements
Rank 1
 answered on 01 Dec 2011
2 answers
124 views
Dear all,
I want to write a javascript function  to check a List using CheckBOX in RADGRID below:

If there is no item is checked=> return false;
If there is one or more item(s) is checked=> return true;

Please help me to do it
Thanks alot,
Ky
Top achievements
Rank 1
 answered on 01 Dec 2011
5 answers
334 views
Hello ,

am using  RadAsyncUpload .
below is my code

 

//To validate upload control.
       function validationFailed(sender, eventArgs) {
           $telerik.$(".ErrorHolder").html("");
           $(".ErrorHolder").append("<p>Attachment exceeding the maximum total size for the file '" + eventArgs.get_fileName() + "'.</p>").fadeIn("slow");
       }
       //Remove Error Message.
       function RemoveErrorMessage(sender, eventArgs) {
           $(".ErrorHolder").fadeOut("slow");
       }

 


 

<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload" MultipleFileSelection="Disabled" TemporaryFolder="attachments"
                            TargetFolder="attachments" MaxFileSize="524288" OnFileUploaded="RadAsyncUpload_FileUploaded"  
                            OnClientValidationFailed="validationFailed" MaxFileInputsCount="1" OnClientFileUploadRemoved="RemoveErrorMessage">
                        </telerik:RadAsyncUpload>


 

public void RadAsyncUpload_FileUploaded(object sender, FileUploadedEventArgs e)
        {
            Label fileName = new Label();
            fileName.Text = e.File.FileName;
            string strFileName = string.Empty;
  
            if (itotalBytes < iMaxTotalBytes)
            {
                // Total bytes limit has not been reached, accept the file
                e.IsValid = true;
                itotalBytes += e.File.ContentLength;
            }
            else
            {
                // Limit reached, discard the file
                e.IsValid = false;
            }
  
            if (e.IsValid)
            {
                string targetFolder = RadAsyncUpload.TargetFolder;
                strFileName = e.File.FileName;
                //If same file uploaded again then it will overwrite.
                e.File.SaveAs(Path.Combine(Server.MapPath(targetFolder), strFileName));
            }
        }

It creates RadUploadTestFile file by default in attachment folder.
Why so?? Can we avoid that?

Plus it creates some wired ext file which i upload ... :(

Mugdha Aditya
Top achievements
Rank 1
 answered on 01 Dec 2011
2 answers
83 views
Hi,
i'm trying to Show and Position the RadDialog on the screen ,but i can't find a way to control the position. So i want to know how can I make ti?
Thank you.
c
Top achievements
Rank 1
 answered on 01 Dec 2011
1 answer
122 views
I am trying to include an user control inside radwindow and trying to open it using readopen but unfortunately this
is not working for me.
<telerik:RadWindow runat="server" ID="RadWindow1" Skin="Vista" KeepInScreenBounds="true" VisibleOnPageLoad="false" Modal="true" Title="Search Client"
       Behaviors="Close,Maximize,Move" Width="500" Height="500">
       <ContentTemplate>
           <cti:ucSearchClient ID="searchClient" runat="server" /> 
       </ContentTemplate>
   </telerik:RadWindow>

On a button click we are trying to call the following javascript method.

function openWindow() {
            var oWnd = radopen(null, "RadWindow1");
        }

Can you please let me know is there a way to open user control using radwindow and get the selected row values into the main page?

we noticed another issue that if we are using Rad Button in place of Html or ASP.net button, it is calling javascript on pageload even before we click and throws error.

Shinu
Top achievements
Rank 2
 answered on 01 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?