Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
1.5K+ views
Hi,

Is there any way to check the length of filename before uploading process? If the length is greater than 80 characters then cancel upload.
Currently the only way to cancel upload is OnClientFilesSelected event but I can not get filename from event argument.

Any help please?

Thanks,
Charlie

Plamen
Telerik team
 answered on 24 Apr 2013
1 answer
190 views
Hi,

I am currently developing RadGrid control in the web form (aspx) and also develop usercontrol (asxc) which has RadTreeView and two buttons (Add and Cancel).

How can I add new items to the RadGridView in the web form when I checked some boxes of the treeview and then clicked "Add" button in the usercontrol? 

I have source code below.

.ASPX 

<telerik:RadGrid ID="rgRequestLocations" runat="server" CellSpacing="0" GridLines="None" AutoGenerateColumns="False"
                                  OnNeedDataSource="rgRequestLocations_NeedDataSource" OnPreRender="rgRequestLocations_PreRender" OnItemInserted="rgRequestLocations_ItemInserted">
                                  <MasterTableView InsertItemDisplay="Top" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add Locations to Request">
                                      <NoRecordsTemplate>
                                          <table>
                                              <tr>
                                                  <td>
                                                      <asp:Label ID="lblNoRecords" runat="server" Style="color: red; font-weight: bold" TabIndex="14">You have not added any locations to the request.</asp:Label></td>
                                              </tr>
                                          </table>
                                      </NoRecordsTemplate>
                                      <Columns>
                                          <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                                          </telerik:GridEditCommandColumn>
                                          <telerik:GridBoundColumn SortExpression="location_pk" HeaderText="Location ID" HeaderButtonType="TextButton"
                                              DataField="location_pk" Visible="false">
                                          </telerik:GridBoundColumn>
                                          <telerik:GridBoundColumn HeaderText="Location Name" HeaderButtonType="TextButton"
                                              DataField="location_name">
                                          </telerik:GridBoundColumn>
                                          <telerik:GridEditCommandColumn ButtonType="PushButton" UniqueName="modify" EditText="Modify">
                                          </telerik:GridEditCommandColumn>
                                          <telerik:GridButtonColumn ButtonType="PushButton" CommandName="Delete" Text="Remove Location" UniqueName="removelocation">
                                          </telerik:GridButtonColumn>
                                      </Columns>
                                      <EditFormSettings EditFormType="WebUserControl" UserControlName="~/Registration/Controls/PO_Registration.ascx">
                                          <EditColumn UniqueName="EditCommandColumn1">
                                          </EditColumn>
                                      </EditFormSettings>
                                  </MasterTableView>
 
                              </telerik:RadGrid>

In the Code-Behind of ASPX

protected void rgRequestLocations_ItemInserted(object sender, GridInsertedEventArgs e)
{
    UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
    //insert a new values
 
    Hashtable newVlaues = new Hashtable();
    newVlaues["Grid"] = (userControl.FindControl("rtvlocation") as RadTreeView).GetAllNodes();
 
}


ASCX
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PO_Registration.ascx.cs" Inherits="Registration_Controls_PO_Registration" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<div style="padding: 10px">
    <telerik:RadDropDownList ID="ddlAdministrations" runat="server" AutoPostBack="true"
        OnSelectedIndexChanged="ddlAdministrations_SelectedIndexChanged">
    </telerik:RadDropDownList>
</div>
<div id="displayTreeViewAdmin" runat="server" visible="false" style="padding: 10px">
    <div>
        <telerik:RadTreeView ID="rtvLocations" runat="server" CheckBoxes="True"
            CausesValidation="False" TriStateCheckBoxes="False" DataFieldID="location_pk"
            DataFieldParentID="parent_fk" DataTextField="location_name" DataValueField="location_pk" />
    </div>
    <div style="padding: 10px">
        <telerik:RadButton ID="btnAddLocations" runat="server" Text="Request Checked Locations" CommandName="Add" Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>' OnClick="btnAddLocations_Click"></telerik:RadButton>
        <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click"></telerik:RadButton>
    </div>
 
</div>

In the code-behind of Ascx

private object _dataItem = null;
 
    public object DataItem
    {
        get
        {
            return this._dataItem;
        }
        set
        {
            this._dataItem = value;
        }
    }
 
#region Control Methods
    override protected void OnInit(EventArgs e)
    {
        InitializeComponent();
        base.OnInit(e);
    }
 
    private void InitializeComponent()
    {
        btnAddLocations.Visible = true;
        PopulateAdminstrations();
    }
    #endregion
 
 
 
#region Button Events
    protected void btnAddLocations_Click(object sender, EventArgs e)
    {
        /*loop through tree, create datatable with appropriate columns, and bind the datatable to radgrid*/
        //create new properties
        const string locationid = "location_id";
        const string locationname = "location_name";
 
        //initizlize new object of datatable level 1
        DataTable dt = new DataTable();
 
        dt.Clear();
 
        //create a new colum for table level 1
        DataColumn dcol = new DataColumn(locationid, typeof(System.Int32));
        dt.Columns.Add(dcol);
 
        dcol = new DataColumn(locationname, typeof(System.String));
        dt.Columns.Add(dcol);
 
        foreach (RadTreeNode row in rtvLocations.GetAllNodes())
        {
            if (row.Checkable)
            {
                if (row.Checked)
                {
                    //Create a new row
                    DataRow drow = dt.NewRow();
                    drow[locationid] = row.Value;
                    drow[locationname] = row.Text;
                    //add row to the datatable
                    dt.Rows.Add(drow);
                }
            }
        }
 
        Session["RequestAdded"] = dt;
 
         
 
    }
 
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        /*Close radgrid edit form*/
    }
    #endregion


Your help is very appericated very well.

Thanks,
Chi Ming 
Kostadin
Telerik team
 answered on 24 Apr 2013
1 answer
129 views
Hi,

I have a list of countries and regions in an xml file and I want to bind Combobox to that xml file. Is it possible to set XmlDataSource to RadComboBox  ?
Kate
Telerik team
 answered on 24 Apr 2013
1 answer
91 views

Hi,

I have converted my solution from vs 2005 to vs2010 using the vs 2010 wizard. when i build the application it was built successfully, however i am getting warning "done with some errors" on the bottom of the page. Which is actually not generating the data in my page.
Before converting the code in view source was -->
Filter by Status:&nbsp;<select name="ctl00$contentContent$ddlStatusFilter" onchange="javascript:setTimeout('window[\'ctl00_contentContent_RadAjaxManager1\'].AsyncRequest(\'ctl00$contentContent$ddlStatusFilter\',\'\')', 0)"  
After converting the code using wizard the same code in view source is visible as-->

            Filter by Status:&nbsp;<select name="ctl00$contentContent$ddlStatusFilter" onchange="javascript:setTimeout(&#39;window['contentContent_RadAjaxManager1'].AsyncRequest(\&#39;ctl00$contentContent$ddlStatusFilter\&#39;,\&#39;\&#39;)&#39;, 0)" id="contentContent_ddlStatusFilter" tabindex="10" style="width:119px;">

If you observe all the " ' " are converted into " &#39; " becuase of this i am getting the error  
Webpage error details

Message: Expected ')'
Line: 119
Char: 21
Code: 0
Please suggest how to resolve this issue. 

Slav
Telerik team
 answered on 24 Apr 2013
2 answers
139 views
Hi,

I can change the ImageUrl after transferring an item from left to right.
BUT if I transfer it to left and then to the right side again. The ImageUrl cannot be change.

Here's the demo:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="Test.WebForm1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
 
<head runat="server">
    <title></title>
    <script type="text/javascript">
        var containerPrefix = '';
        var trvElementsID = containerPrefix + 'trvElements';
        var trvQueriesID = containerPrefix + 'trvQueries';
        var trvOrdersID = containerPrefix + 'trvOrders';
        var trvRangesID = containerPrefix + 'trvRanges';
        var lsbOrderItemTargetID = containerPrefix + 'lsbOrderItemTarget';
        var hidQueriesChangedID = containerPrefix + 'hidQueriesChanged';
        var hidOrdersChangedID = containerPrefix + 'hidOrdersChanged';
        var hidRangesChangedID = containerPrefix + 'hidRangesChanged';
         
        function ToggleSort(sender, args) {
            //    debugger;
            var imgAsc = 'ascending.png';
            var imgDesc = 'descending.png';
            var listboxTarget = $find(lsbOrderItemTargetID);
 
            if (listboxTarget) {
                var selectedItem = listboxTarget.get_selectedItem();
 
                if (selectedItem) {
                    listboxTarget.trackChanges();
                    //imageUrl
                    var oldImgUrl = selectedItem.get_imageUrl();
                    var arrUrl = oldImgUrl.split("/");
 
                    //value
                    var oldValue = selectedItem.get_value();
                    var arrValue = oldValue.split(".");
 
                    if (arrValue[0] == 'asc') {
                        arrValue[0] = 'desc';
                        arrUrl[arrUrl.length - 1] = imgDesc;
                    } else {
                        arrValue[0] = 'asc';
                        arrUrl[arrUrl.length - 1] = imgAsc;
                    }
 
                    var newImgUrl = arrUrl.join("/");
                    var newValue = arrValue.join(".");
                     
                    selectedItem.set_value(newValue);
                    selectedItem.set_imageUrl(newImgUrl);
                    listboxTarget.commitChanges();
                }
                else {
                    alert('no item selected');
                }
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" ScriptMode="Release" EnableScriptLocalization="true" EnableScriptGlobalization="true"
        CombineScripts="false" runat="server" EnablePartialRendering="true" />
 
        <div>
        <telerik:RadListBox ID="lsbOrderItemSource" SelectionMode="Multiple" AllowTransfer="true" AllowReorder="false" TransferToID="lsbOrderItemTarget"
            PersistClientChanges="true" Skin="Outlook" runat="server" Height="500px" Width="30%" >
                <Items>
                    <telerik:RadListBoxItem Text="test1" ImageUrl="Images/ascending.png"/>
                    <telerik:RadListBoxItem Text="test2" ImageUrl="Images/ascending.png"/>
                    <telerik:RadListBoxItem Text="test3" ImageUrl="Images/ascending.png"/>
                    <telerik:RadListBoxItem Text="test4" ImageUrl="Images/ascending.png"/>
                </Items>
            </telerik:RadListBox>
 
        <telerik:RadButton runat="server" ID="teleriktoggle" Text="ASC/DESC" OnClientClicked="ToggleSort" AutoPostBack="false"></telerik:RadButton>
        <telerik:RadListBox ID="lsbOrderItemTarget" SelectionMode="Multiple"
            AllowReorder="true" Skin="Outlook" runat="server" Height="500px" Width="30%" PersistClientChanges="true"/>
        </div>
    </div>
    </form>
</body>
</html>


Thanks in advance for your help.
Christian.
Nencho
Telerik team
 answered on 24 Apr 2013
1 answer
157 views
I find out that RadFormDecorator adds its classes  rfdRoundedCorners rfdDecorated after an ajax call. Let's say I have a couple of RadTextBox and a checkbox inside a <div> wich will be ajaxified.
I want to style the checkbox so I add RadFormDecorator.
On the first page load, my RadTextBoxes will have just their classes: riSingle RadInput (plus eventual specific skin) When I trigger the ajax postback and the div updates the same textboxes will have rfdRoundedCorners rfdDecorated classes added by the form decorator. This may seem like an "innocent" behaviour but is not since this will change your css specificity. So if for example you override textboxes css with: html body .RadInput .riTextBox, html body .RadInputMgr  { }
This will work on a fresh pageload but won't work anymore after the ajax update, screwing up the rendering of the textboxes.
A quick fix is of course to add !important inside the css overrides, but I'm wondering if this behaviour is intended and if there is some easy workaround instead of using the !important clause in our css.

Thanks in advance


Danail Vasilev
Telerik team
 answered on 24 Apr 2013
1 answer
106 views
It seems that when you set Animation="Fade" the tooltip callout won't fade just "pop" with an unpleasant effect even on short  fades.
Is there a way to override this behaviour? .

Also it seems that this trick to override default auto-adjust behaviour won't work anymore:
Telerik.Web.UI.RadToolTip.prototype._adjustCallout = function () {
}

Wich is the actual jQuery alternative for this?

Thanks in advance
Marin Bratanov
Telerik team
 answered on 24 Apr 2013
1 answer
96 views
Hi,

I want to alert the allowed file extension when the user try to upload files of unsupported extensions. Please help soon.. Urgent requirement.

Thanks for reply in advance,
K.R
Shinu
Top achievements
Rank 2
 answered on 24 Apr 2013
1 answer
100 views
Set frameDuration from XML

I don't believe this is supported, although it would be a welcome upgrade.

Any suggestions on how to work-around this issue?

many thanks.
Slav
Telerik team
 answered on 24 Apr 2013
1 answer
110 views
On FireFox and Safari on Macs running OS X 10.6.8, the insert link tool on RadEditor is not working properly.
On Windows 7 Chrome it works perfectly. 

The issue:
Type a sentence into RadEditor, highlight a word at the beginning of the sentence, click the insert link button, type in a web address. Works fine. Highlight a word later in the sentence, click the insert link button and add a web address and RadEditor will delete all the content between the two links. As said, works fine on Chrome on Windows. 

Using Telerik 2012.3.1308.40 on ASP .NET 4.0 Server. 

I setup a test page in my project which only has a simple RadEditor on it:
Thanks in advance.
<form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI"
                Name="Telerik.Web.UI.Common.Core.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI"
                Name="Telerik.Web.UI.Common.jQuery.js">
            </asp:ScriptReference>
            <asp:ScriptReference Assembly="Telerik.Web.UI"
                Name="Telerik.Web.UI.Common.jQueryInclude.js">
            </asp:ScriptReference>
        </Scripts>
    </telerik:RadScriptManager>
    <div>
     
    <telerik:RadEditor ID="radEditTestCompleteEmail" Runat="server"
                                          EditModes="Design" Width="441px"
            StripFormattingOptions="MSWordRemoveAll"
            StripFormattingOnPaste="MSWordRemoveAll">
                                          <CssFiles>
                                              <telerik:EditorCssFile Value="~/radEditorContentArea.css" />
                                          </CssFiles>
                                          <Tools>
                                              <telerik:EditorToolGroup>
                                                  <telerik:EditorTool Name="Bold" />
                                                  <telerik:EditorTool Name="Italic" />
                                                  <telerik:EditorTool Name="Underline" />
                                                  <telerik:EditorTool Name="InsertLink" />
                                                  <telerik:EditorDropDown Name="FontName">
                                                  </telerik:EditorDropDown>
                                                  <telerik:EditorDropDown Name="FontSize">
                                                  </telerik:EditorDropDown>
                                                  <telerik:EditorTool Name="FindAndReplace" />
                                                  <telerik:EditorTool Name="PasteFromWordNoFontsNoSizes" />
                                                  <telerik:EditorSplitButton Name="Redo">
                                                  </telerik:EditorSplitButton>
                                                  <telerik:EditorSplitButton Name="Undo">
                                                  </telerik:EditorSplitButton>
                                              </telerik:EditorToolGroup>
                                          </Tools>
                                          <Content>
</Content>
                                          <TrackChangesSettings CanAcceptTrackChanges="False" />
                                      </telerik:RadEditor>

         
Stamo Gochev
Telerik team
 answered on 24 Apr 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?