Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
101 views
in the file explorer
from the folder pane I will delete a folder 
after deleting I want to select the first folder and do refresh
Dobromir
Telerik team
 answered on 15 Apr 2010
9 answers
143 views
Hi, 
Can someone please tell me how to spell check multiple controls on the client-side? It seems that there used be a demo on the website, but I guess it was replaced when server-side ControlIdSToCheck got implemented.

I would like to spell check a few pre existing textbox/textareas and also few textboxes that were created dynamically via js on the client-side, all by clicking on a single "Spell check" button.
 
Thanks a lot!!
Kate 
Rumen
Telerik team
 answered on 15 Apr 2010
1 answer
148 views
Hi
I am having an issue using an image control as an opener element for the window, but if I use a div it works fine.
I can't see what's wrong with this - or can't I use an image in this way?

Thanks for any hints

Clive
using version Q2 2009
<telerik:RadWindow ID="RadWindow1" runat="server"   
        OpenerElementID="imageClick" NavigateUrl="images/PETRUS-1med.jpg"   
        Animation="Fade" VisibleStatusbar="False"   
        BackColor="#5F6060" Height="710px" Width="600px">     
</telerik:RadWindow> 
 
 
<asp:Image ID="imageClick" runat="server"   
            ImageUrl="images/PETRUS-1small.jpg"   
            AlternateText="Chateau Petrus" Width="250px"   
            CssClass="chateau-pics-small"   
            ToolTip="Click for larger image" /> 
Clive Hoggar
Top achievements
Rank 1
 answered on 15 Apr 2010
2 answers
224 views
When using the RadProgressArea in a custom monitoring scenario what is the prescribed way to handle the cancel operation on the server side?  I am looping through a collection of items, doing stuff and I want to check something like RadProgressContext.Current.HasCancelBeenClicked.  Here is what I have so far.  I am getting some odd behavior on cancel along with the progress bar percentage part not updating.  If you try to invoke it a second time nothing updates.

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" %> 
 
<%@ Import Namespace="System.Collections.Generic" %> 
<%@ Import Namespace="System.Threading" %> 
<%@ Import Namespace="Telerik.Web.UI" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Long running operation with Cancel support example</title> 
    <style type="text/css"
        .Hide 
        { 
            display: none; 
        } 
    </style> 
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="ScriptManager" runat="server" EnableHistory="true" 
        EnableScriptCombine="true" OutputCompression="AutoDetect"
        <Scripts> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
        </Scripts> 
    </telerik:RadScriptManager> 
    <telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel" runat="server" Skin="Default" /> 
    <telerik:RadAjaxManager ID="AjaxManager" runat="server" DefaultLoadingPanelID="AjaxLoadingPanel"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="DoWork"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="DoWork" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="CancelWork"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="CancelWork" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadWindowManager ID="WindowManager" runat="server" /> 
    <asp:Button ID="ShowOptionsDialog" runat="server" CausesValidation="false" OnClientClick="ShowOptionsDialog_Click(); return false;" 
        Text="Go!" /> 
    <asp:Button ID="DoWork" runat="server" CausesValidation="false" CssClass="Hide" OnClick="DoWork_Click" /> 
    <asp:Button ID="CancelWork" runat="server" CausesValidation="false" CssClass="Hide" 
        OnClick="CancelWork_Click" /> 
    <asp:HiddenField ID="DoWorkParameters" runat="server" /> 
    <asp:HiddenField ID="OperationId" runat="server" /> 
    <telerik:RadCodeBlock runat="server"
        <script type="text/javascript"
            window.$ = $telerik.$; 
 
            function ShowOptionsDialog_Click() { 
                var optionsDialog = $find('<%= OptionsDialog.ClientID %>'); 
                optionsDialog.show(); 
            } 
 
            function OptionsDialog_Close(sender, e) { 
                var result = e.get_argument(); 
                if (result) { 
                    var progressArea = $find($('[id$=_ProgressArea]').attr('id')); 
                    progressArea.show(); 
 
                    var cancelButton = progressArea._findElement("CancelButton"); 
                    $addHandlers(cancelButton, { "click": ProgressDialog_Cancel }, this); 
 
                    var progressDialog = $find('<%= ProgressDialog.ClientID %>'); 
                    progressDialog.show(); 
 
                    $('<%= "#" + DoWorkParameters.ClientID %>').val(result); 
 
                    // TODO: get an operation ID with AJAX 
                    var operationId = "{EE1B4300-CF80-4CF1-9C01-5E6412DAEC00}"
 
                    $('<%= "#" + OperationId.ClientID %>').val(operationId); 
                    $get('<%= DoWork.ClientID %>').click(sender, e); 
                } 
            } 
 
            function ProgressDialog_Cancel(sender, e) { 
                $get('<%= CancelWork.ClientID %>').click(sender, e); 
                return false; 
            } 
 
            function ProgressDialog_Close(title, message) { 
                var progressArea = $find($('[id$=_ProgressArea]').attr('id')); 
                progressArea.hide(); 
 
                var progressDialog = $find('<%= ProgressDialog.ClientID %>'); 
                progressDialog.close(); 
 
                var resultsDialog = $find('<%= ResultsDialog.ClientID %>'); 
                resultsDialog.set_title(title); 
                resultsDialog.argument = message
                resultsDialog.show(); 
            } 
 
            Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler); 
            function BeginRequestHandler(sender, args) { 
                var elem = args.get_postBackElement(); 
                if (elem.id == '<%= CancelWork.ClientID %>') { 
                    args.set_cancel(false); 
                } 
            } 
        </script> 
    </telerik:RadCodeBlock> 
    <telerik:RadWindow ID="OptionsDialog" runat="server" Behaviors="Move, Resize, Close" 
        KeepInScreenBounds="true" Modal="true" NavigateUrl="~/Options.aspx" OnClientClose="OptionsDialog_Close" 
        ReloadOnShow="true" ShowContentDuringLoad="false" Title="Operation Options" VisibleStatusbar="false" /> 
    <telerik:RadWindow ID="ProgressDialog" runat="server" Behaviors="None" KeepInScreenBounds="true" 
        Height="250px" Modal="true" ShowContentDuringLoad="false" VisibleTitlebar="false" 
        VisibleStatusbar="false" Width="500px"
        <ContentTemplate> 
            <telerik:RadProgressArea ID="ProgressArea" runat="server" DisplayCancelButton="true" 
                ProgressIndicators="CurrentFileName,TimeElapsed,TimeEstimated,TotalProgress,TotalProgressBar,TotalProgressPercent" 
                Width="100%" /> 
            <telerik:RadProgressManager ID="ProgressManager" runat="server" /> 
        </ContentTemplate> 
    </telerik:RadWindow> 
    <telerik:RadWindow ID="ResultsDialog" runat="server" Behaviors="Move, Resize, Close" 
        KeepInScreenBounds="true" Modal="true" NavigateUrl="~/Results.aspx" ReloadOnShow="true" 
        ShowContentDuringLoad="false" VisibleStatusbar="false" /> 
    </form> 
</body> 
</html> 
<script runat="server"
     
    static Dictionary<Guid, WorkState> stateDictionary = new Dictionary<Guid, WorkState>(); 
 
    protected void DoWork_Click(object sender, EventArgs e) 
    { 
        var stateId = new Guid(OperationId.Value); 
        stateDictionary.Add(stateId, new WorkState { Argument = DoWorkParameters.Value }); 
 
        ThreadPool.QueueUserWorkItem(DoActualWork, stateId); 
 
        var state = stateDictionary[stateId]; 
        while (!state.IsComplete) 
        { 
            RadProgressContext.Current.CurrentOperationText = state.Message ?? string.Empty; 
            RadProgressContext.Current.PrimaryPercent = state.PercentComplete; 
            Thread.Sleep(500); 
        } 
 
        var resultTitle = !state.IsAborted ? "Operation successful!" : "Operation failed."; 
        var resultMessage = !state.IsAborted ? "Your request was fulfilled." : "Your request was canceled"; 
        RadProgressContext.Current.OperationComplete = true
        RadAjaxManager.GetCurrent(this).ResponseScripts.Add(string.Format("ProgressDialog_Close('{0}', '{1}');", resultTitle, resultMessage)); 
        stateDictionary.Remove(stateId); 
    } 
 
    protected void CancelWork_Click(object sender, EventArgs e) 
    { 
        var stateId = new Guid(OperationId.Value); 
        if (stateDictionary.ContainsKey(stateId)) 
        { 
            stateDictionary[stateId].AbortRequested = true
        } 
    } 
 
    void DoActualWork(object o) 
    { 
        var state = stateDictionary[(Guid)o]; 
        var maxItems = 20
 
        for (var itemIndex = 0; itemIndex < maxItems; itemIndex++) 
        { 
            System.Diagnostics.Debug.Write(itemIndex); 
 
            state.Message = string.Format("Operation {0} - {1}", state.Argument, itemIndex); 
            state.PercentComplete = itemIndex / maxItems * 100; 
            Thread.Sleep(1000); 
 
            if (state.AbortRequested) 
            { 
                state.IsAborted = true
                break; 
            } 
        } 
        state.IsComplete = true
    } 
 
    class WorkState 
    { 
        public object Argument; 
        public string Message; 
        public int PercentComplete; 
        public bool IsComplete; 
        public bool AbortRequested; 
        public bool IsAborted; 
    } 
</script> 
 

Options.aspx:
<%@ Page Language="C#" AutoEventWireup="true" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<body> 
    <form id="form1" runat="server"
    <div> 
        <input id="Name" type="text" value="Calculate Pii" /> 
    </div> 
    <div> 
        <button onclick="Close(document.getElementById('Name').value);"
            Go!</button> 
        <button onclick="Close(null);"
            Cancel</button> 
    </div> 
    <script type="text/javascript"
        function GetRadWindow() { 
            var radWindow = null
            if (window.radWindow) { 
                radWindow = window.radWindow; 
            } 
            else if (window.frameElement.radWindow) { 
                radWindow = window.frameElement.radWindow; 
            } 
            return radWindow; 
        } 
 
        function Close(returnValue) { 
            var radWindow = GetRadWindow(); 
            if (returnValue == undefined) { 
                radWindow.argument = null
                radWindow.close(); 
            } 
            else { 
                radWindow.close(returnValue); 
            } 
        } 
    </script> 
    </form> 
</body> 
</html> 
 


Result.aspx:

<%@ Page Language="C#" AutoEventWireup="true" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="ScriptManager" runat="server" EnableHistory="true" 
        EnableScriptCombine="true" OutputCompression="AutoDetect"
        <Scripts> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
        </Scripts> 
    </telerik:RadScriptManager> 
    <div id="Message"
    </div> 
    <input type="button" value="Close" onclick="Close(null);" /> 
    <script type="text/javascript"
        window.$ = $telerik.$; 
 
        function GetRadWindow() { 
            var radWindow = null
            if (window.radWindow) { 
                radWindow = window.radWindow; 
            } 
            else if (window.frameElement.radWindow) { 
                radWindow = window.frameElement.radWindow; 
            } 
            return radWindow; 
        } 
 
        function Close(returnValue) { 
            var radWindow = GetRadWindow(); 
            if (returnValue == undefined) { 
                radWindow.argument = null
                radWindow.close(); 
            } 
            else { 
                radWindow.close(returnValue); 
            } 
        } 
 
        $(document).ready(function () { 
            var window = GetRadWindow(); 
            $("#Message").text(window.argument); 
        }); 
    </script> 
    </form> 
</body> 
</html> 
 

Genady Sergeev
Telerik team
 answered on 15 Apr 2010
1 answer
99 views
I have the following code
protected void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
        {  
            if (e.Item is GridFilteringItem)  
            {  
                RadGrid2.MasterTableView.FilterExpression = "([Active] = true) ";  
                GridColumn column = RadGrid2.MasterTableView.GetColumnSafe("Active");  
                column.CurrentFilterFunction = GridKnownFunction.EqualTo;  
                column.CurrentFilterValue = "True";  
            }  
        } 

I then later in jave script use
nestedView.get_filterExpressions().toDynamicLinq()  
 
to get the current filter.  The problem is when I hit this line of code It cliams the filter if blank.  Am I missing something?

Just some more backgroud.  This is happening in a nested grid taht is nested by use of panels.  The ItemCreated is running when the page loads, then when the use selects a record from RadGrid1 it runs a webservice that getst the data then in java script updates the nested grid.
Pavlina
Telerik team
 answered on 15 Apr 2010
1 answer
74 views
Hi,

  I am using spell check component on the webpart. The webpart loads 5 usercontrol and display the appropriate page based on the event. I have added the spell checker on each user control and associate this with the respective text boxes. As the spellchecker needs the scriptmanager on the page before loading the spellcheck component, I have dynamically loaded the scriptmanager on the page init method of the webpart. The spellchecker works fine but the viewstate values disappear. Later I replaced the Scriptmanager with Radscript manager(Had a thought that the Rad scriptmanager must be customised for the state management), but still have the similar issue.

 Later again, I register the Radscriptmanager on the ASPX page where the webpart is loaded, that was working fine and view state appear properly. But when I publish the page, it start throwing the error (Message: Script manager must be registered before RadSpell control. Message: RadSpell must be registered before prerender)

I am a bit stressed at the moment as we are already have missed the deadline. 

I am hoping to get the immediate resolution of this issue.

Thanks
Dhananjay 
Rumen
Telerik team
 answered on 15 Apr 2010
1 answer
139 views
Hello! I have a small problem, I have a grid within a RadPane when I slide down and select a row in the grid the scroll bar is coming back up and I lose the selected row.
As I can do to stop the scroll bar fixed and prevent a return to the top?

Thanks for the help.
Best regards.

Bryan
Svetlina Anati
Telerik team
 answered on 15 Apr 2010
2 answers
245 views
Hi,

We have an issue where after closing a rad window (that is opened from a button in a grid using the ItemCommand) the page will do a post back to reload the grid after which the rad window automatically reopens.

This function used to work fine without the rad window reopening. If I remove the rebind command from the close function the rad window does not reopen, however if you then cause the grid to rebind the window will reopen afterwards.

The only changes I know have been done before it was noticed that this page now had an error, were an upgrade to the latest Telerik controls and the addtion of a method to keep the grid selections. (note that this is an Hierarchy grid and the button is on the data table not the master table)

the Item command is as follows:
       if (e.CommandName == "GenerateExhibit")
            {
                GridDataItem item = (GridDataItem)e.Item;
                //Get the primary key value using the DataKeyValue.    
                string url = "~/Modules/Dialog/GenerateNewExhibit.aspx";
                string arguments = "?Location=Chemical Lab";
                arguments += "&IncidentId=" + IncidentId.ToString();
                arguments += "&ParentExhibitId=" + item["ExhibitId"].Text;
                arguments += "&ExtraDetail=" + item["Treatment"].Text;
                RadWindow window = new RadWindow();
                window.Title = "Generate New Exhibit";
                window.ID = "rwGenerateNewExhibitDialogWindow";
                window.NavigateUrl = url + arguments;
                window.OnClientClose = "OnClientCloseGenerateNewExhibit";         
                window.Behaviors = WindowBehaviors.Close;
                window.KeepInScreenBounds = true;
                window.VisibleStatusbar = false;
                window.Modal = true;
                window.Width = 1000;
                window.Height = 750;
                window.VisibleOnPageLoad = true;
                rwmGenerateNewExhibit.Windows.Add(window);
            }

the client side close function is:
            function OnClientCloseGenerateNewExhibit(radWindow) {
                grdRelatedExhibits = $find("<%= grdRelatedExhibits.ClientID %>");
                grdRelatedExhibits.get_masterTableView().rebind();
                //alert("Closing");
            }

the methods to 'remeber selection and expantion'
protected void grdRelatedExhibits_DataBound(object sender, EventArgs e)
        {
            //Expand all items using our custom storage
            string[] indexes = new string[this.ExpandedStates.Keys.Count];
            this.ExpandedStates.Keys.CopyTo(indexes, 0);

            ArrayList arr = new ArrayList(indexes);
            //Sort so we can guarantee that a parent item is expanded before any of
            //its children
            arr.Sort();

            foreach (string key in arr)
            {
                bool value = (bool)this.ExpandedStates[key];
                if (value)
                {
                    try
                    {
                        grdRelatedExhibits.Items[key].Expanded = true;
                    }
                    catch
                    {
                    }
                }
            }

            //Select all items using our custom storage
            indexes = new string[this.SelectedStates.Keys.Count];
            this.SelectedStates.Keys.CopyTo(indexes, 0);

            arr = new ArrayList(indexes);
            //Sort to ensure that a parent item is selected before any of its children
            arr.Sort();

            foreach (string key in arr)
            {
                bool value = (bool)this.SelectedStates[key];
                if (value)
                {
                    try
                    {
                        grdRelatedExhibits.Items[key].Selected = true;
                    }
                    catch
                    {
                    }
                }
            }
        }

Item command for expand/contract/select/deselect
if (e.CommandName == RadGrid.ExpandCollapseCommandName)
            {
                //Is the item about to be expanded or collapsed
                if (!e.Item.Expanded)
                {
                    //Save its unique index among all the items in the hierarchy
                    this.ExpandedStates[e.Item.ItemIndexHierarchical] = true;
                }
                else //collapsed
                {
                    this.ExpandedStates.Remove(e.Item.ItemIndexHierarchical);
                    this.ClearExpandedChildren(e.Item.ItemIndexHierarchical);
                }
            }
            //Is the item about to be selected
            else if (e.CommandName == RadGrid.SelectCommandName)
            {
                //Save its unique index among all the items in the hierarchy
                this.SelectedStates[e.Item.ItemIndexHierarchical] = true;
            }
            //Is the item about to be deselected
            else if (e.CommandName == RadGrid.DeselectCommandName)
            {
                this.SelectedStates.Remove(e.Item.ItemIndexHierarchical);
            }

Thanks in advance
Paul



Paul Gothard
Top achievements
Rank 1
 answered on 15 Apr 2010
6 answers
442 views
I am using a RadGrid and utilizing the popup edit mode.

For simplicity sake, I have 2 DropDown lists (although these could easily be RadComboBoxes).  In the first one I have Countries, and the second one I have Cities.  Select a Country, the second DropDownList is populated with Cities.  Pretty standard functionality, nothing special here.

I would like to bind the selected values to an object's properties.  Lets say an Address object's .CountryID and .CityID properties for sake of argument.

<telerik:RadComboBox ID="ddlCountries" Runat="server" SelectedValue='<%#Bind("CountryID") %>' AutoPostBack="true" DataSourceID="countriesDataSource"  DataTextField="Country" DataValueField="CountryID"/>  
 
<telerik:RadComboBox ID="ddlCities" Runat="server" SelectedValue='<%#Bind("CityID") %>' DataSourceID="citiesDataSource"  DataTextField="City" DataValueField="CityID"/> 

ddlCountries can bind to the object fine in either edit or insert mode.  The problem lies in when ddlCities attempts to bind to the object.  I forget the exception that is thrown at this point, but it has something to do with ddlCities not being a bindable object.

I have figured out a solution to get this to work.  Admittedely, it is far more hackish than I hoped it to be.  I basically have to populate ddlCities manually after ddlCountries has changed and manually populate ddlCities with values (can't use a DataSource object).  What's worse is that I have to handle a few RadGrid events to manually select the City that should bind to the object's City property, rather than allow the elegance of the Bind() method to perform its work.  Again, it works, but it's quite an ugly solution.

Has anyone experienced this and have a code sample that they'd like to share?  I can share mine to upon request.

Thanks!
Pavlina
Telerik team
 answered on 15 Apr 2010
2 answers
155 views
So what I want to achieve is to display the rad editor as a textbox...no tools, nothing.
I've tried this multiple times, and can't seem to do this right.
I want to display it as this so I can pull the text without html .

Nate
Nate
Top achievements
Rank 1
 answered on 15 Apr 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?