Telerik Forums
UI for ASP.NET AJAX Forum
7 answers
670 views
Hi there,

I have searched high and low for an answer to this, however can't seem to get any of them working, so here goes...

I have a WebForm with a single RadGrid Q3 2009 and a RadAjaxManager control.  The RadGrid has AllowFilteringByColumn enabled. The WebForm has a MasterPage, which has RadScriptManager and a RadAjaxLoadingPanel. In the RadGrid, one of my columns is an ImageButton GridButtonColumn (with RadWindow Confirm).  In the RadGrid1_ItemDataBound I set the CommandArgument of the button.  In RadGrid1_ItemCreated, I use Master.FindControl to find the RadScriptManager, and call .RegisterPostBackControl(button).  This causes the ImageButton to create a full PostBack as expected.

The problem is that this stops working after an AsyncPostBack has occurred.  For instance, when the RadGrid is filtered on any column, an AsyncPostBack occurs.  If I click on the same button which caused a full PostBack before, it now causes another AsyncPostBack which I do not want. I'd really appreciate any help, I have put together a simple WebSite project to demonstrate this, which I will email if you need it.

Essentially, the important code is as follows:
Master Page:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!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></title>  
    <asp:ContentPlaceHolder id="head" runat="server">  
    </asp:ContentPlaceHolder> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
         <telerik:RadAjaxLoadingPanel  ID="RadAjaxLoadingPanel1" runat="server" > 
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border:0;" /> 
        </telerik:RadAjaxLoadingPanel>    
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">  
          
        </asp:ContentPlaceHolder> 
    </div> 
    </form> 
</body> 
</html> 

WebForm:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">  
</asp:Content> 
 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">  
 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager>    
          
    <telerik:RadGrid ID="RadGrid1" runat="server"   
        AllowPaging="True"    
        VirtualItemCount="100" 
        datasourceid="ObjectDataSource1" 
        GridLines="None"   
        Skin="Windows7"   
        AllowFilteringByColumn="True"    
        EnableLinqExpressions="false" 
        onitemcommand="RadGrid1_ItemCommand"   
        onitemcreated="RadGrid1_ItemCreated"   
        onitemdatabound="RadGrid1_ItemDataBound">    
        <GroupingSettings CaseSensitive="false" />           
        <MasterTableView autogeneratecolumns="False" DataKeyNames="ID" > 
            <PagerStyle AlwaysVisible="true" /> 
            <Columns> 
                <telerik:GridButtonColumn ConfirmText="View this item?" ConfirmDialogType="RadWindow" 
                    ConfirmTitle="View Item" ButtonType="ImageButton" CommandName="View" Text="View" 
                    UniqueName="ViewColumn" ItemStyle-Width="15px" ImageUrl="~/Images/newContact.gif">  
                </telerik:GridButtonColumn>                              
                  
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name"   
                    SortExpression="Name" UniqueName="Name" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true">  
                </telerik:GridBoundColumn>                  
            </Columns> 
        </MasterTableView> 
        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> 
         
    </telerik:RadGrid> 
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"   
        EnablePaging="true" 
        DataObjectTypeName="Title"   
        OldValuesParameterFormatString="original_{0}"   
        SelectMethod="GetTitles"   
        SelectCountMethod="GetTitlesCount" 
        TypeName="DataAccess">  
    </asp:ObjectDataSource> 
    <telerik:RadWindowManager  ID="RadWindowManager1" runat="server"></telerik:RadWindowManager> 
      
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
 </asp:Content> 
 
 

Code-Behind:
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
 
public partial class _Default : System.Web.UI.Page  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
 
    }  
 
    protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
        string commandname = e.CommandName;  
        string commandArgument = e.CommandArgument.ToString();  
 
        if (commandname.Equals("View") && !string.IsNullOrEmpty(commandArgument))  
        {  
            int id = int.Parse(commandArgument);  
 
            Label1.Text = "You clicked item id: " + id.ToString();  
        }  
    }  
 
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        // make the View ImageButtons PostBackControls  
        if (e.Item is GridDataItem)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            ImageButton viewButton = (ImageButton)item["ViewColumn"].Controls[0];  
 
            ScriptManager.GetCurrent(Page).RegisterPostBackControl(viewButton);  
 
            //viewButton.Attributes.Add("onclick", string.Format("realPostBack(\"{0}\", \"\"); return false;", viewButton.UniqueID));  
            //viewButton.OnClientClick = String.Format("{0}.__doPostBack(\"{1}\",\"{2}\");return false;", RadGrid1.ClientID, viewButton.UniqueID, viewButton.CommandArgument);  
            //RadScriptManager rsm = Master.FindControl("RadScriptManager1") as RadScriptManager;  
            //if (rsm != null)  
            //{  
            //    rsm.RegisterPostBackControl(viewButton);  
            //}  
        }  
    }  
 
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            (item["ViewColumn"].Controls[0] as ImageButton).CommandArgument = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString(); ;  
        }  
    }  


I have tried adding the __doPostBack(...) Javascript call on to the ImageButton instance per the solution in this post http://www.telerik.com/help/aspnet-ajax/ajxexclude.html, but that didn't work for me. I have tried using a regular ScriptManager instead of the RadScriptManager too, to no avail.

Many thanks,

Anthony
Rosemary
Top achievements
Rank 1
 answered on 21 Apr 2010
1 answer
202 views
I have an application where the end user has two ways of entering data.  The first method is though a form where the user can select various values from  ComboBoxes and/or enter values in text fields.  The second method involves a direct load into the database from an excel spreadsheet.

What I am discovering is that for one particular field, in this case a RadComboBox, if I create the record using the asp.net form and Telerik controls and then later go back and redisplay the record using the same form, everything works.  But if I load the data into the database directly, even though I have verified through SQL the data values for this field are correct, the value is never loaded into the ComboBox.  Instead the value reverts to the first item in my dropdown list.

I have verified though my Visual Studio debugger that the value is being read from the database and written into the appropriate memory location, but as soon as the page renders in the browser, the value is lost.  There is no custom Javascript code running on the client, which leads me to think the issue must be in the control itself.

What is even stranger is that I have other combo boxes on the same page that are able to display the select database values without a problem, regardless of how the values were set.

Does anyone have any clues or ideas would be greatly appreciated.

Regards,



Steve
Steve Lundy
Top achievements
Rank 1
 answered on 21 Apr 2010
4 answers
187 views
I just purchased RadControls_for_ASP.NET_AJAX_2010_1_309 but I have an older trial version (RadControls_for_ASP.NET_AJAX Q1 2009) installed on my computer.

Any "best practices" for overwriting the old with the new?

Thanks
Brendan Casey
Top achievements
Rank 1
 answered on 21 Apr 2010
2 answers
169 views
Hello,

I would like to request that Telerik add standard CSS support to it's ASP.NET AJAX controls, including the tabstrip. Specifically, the control's have all of their skins embedded in the DLL - which is great. But the controls also have their own font-size, etc properties that should be able to over-ride the embedded CSS files. This is just standard CSS design: locally defined styles should over-ride a stylesheet.

The standard CSS hiearchy is follows:

1. The order that you put the <link> reference to the style sheet at the top of the page determines the order the styles are loaded and any styles in the last sheet that are loaded that exist in the previous sheet will be over-ridden.

2. The same applies to actual <style> tags added to a page, where the styles further down in the style tag will over-ride any others if so similarly named.

3. Lastly, any style="" attribute placed on an individual control takes ABSOLUTE preference over any styles declared in <style> tags or separate styles sheets. This should also include the specific font-size, etc properties on the control itself.

It would be nice if the controls supported this standard CSS approach so that I didn't have to switch off the embedded support, copy the whole style sheet for the tabstrip, all just to modify the tab's text size. If the control was following 'standard css norms' I should be able to use the control's "font-size" property to over-ride any settings in the embedded CSS file. Otherwise it doesn't even made sense to expose that useless 'font-size' property.

Could this support for the standard CSS hierarchy be added in a future release of the ASP.NET AJAX controls?

Thanks,
Chris
Christian Bruckhoff
Top achievements
Rank 1
 answered on 21 Apr 2010
2 answers
145 views
We have a sharepoint page with several AJAX enabled controls and webparts on a page.  We have a RadTreeView, a RadGrid, and a message panel. 

When we click in the grid, be it sorting or handling a row event, all three progress indicators on the page animate.

Unfortunately I cannot post any source code, so I hope this behavior rings a bell with someone. 
jonathan hart
Top achievements
Rank 1
 answered on 21 Apr 2010
1 answer
340 views
The File Explorer control displays an error message if the file is larger than what is set for the control (Assuming that the setting in the web.config is not exceeded.).

I set the control to 3mb, and the web.config to 10mb.

Is it possible to display the same message for the readupload control?


This control resides as an edit item template within a grid which is located in a user control

                                                                    <telerik:GridTemplateColumn UniqueName="Upload" HeaderText="File Name">  
                                                                        <ItemTemplate> 
                                                                            <asp:HyperLink ID="hlFile" runat="server" Target="_blank" /> 
                                                                        </ItemTemplate> 
                                                                        <EditItemTemplate> 
                                                                            <table cellpadding="0" cellspacing="0" border="0">  
                                                                                <tr valign="top">  
                                                                                    <td> 
                                                                                        <asp:Label ID="lblValidFileTypesMessage" runat="server" Font-Size="X-Small" /> 
                                                                                    </td> 
                                                                                </tr> 
                                                                                <tr valign="top">  
                                                                                    <td style="height:40px;">  
                                                                                        <telerik:RadUpload ID="RadUpload1" runat="server" MaxFileInputsCount="1" InitialFileInputsCount="1" 
                                                                                            ControlObjectsVisibility="None" OverwriteExistingFiles="true" /> 
                                                                                    </td> 
                                                                                </tr> 
                                                                            </table> 
                                                                        </EditItemTemplate> 
                                                                    </telerik:GridTemplateColumn> 
 
Atlas
Top achievements
Rank 1
 answered on 21 Apr 2010
3 answers
629 views
Hi there.

How would I iterate through the DataSource of a grid? I have items that are not in a column, but are part of the datasource that I need to get at.

Thanks, Mike
robertw102
Top achievements
Rank 1
 answered on 21 Apr 2010
3 answers
168 views
I'm trying to use a ColorPicker in a DetailView to allow a user to change the assigned color of a matching record. Below is my code:

<asp:TemplateField>   
<HeaderStyle/>   
<HeaderTemplate>AssignedColor:</HeaderTemplate>   
<EditItemTemplate><telerik:radcolorpicker ID="rcpAssignedColor" runat="server" preset="Standard" SelectedColor='<%#Bind("AssignedColor")%>'></telerik:radcolorpicker></EditItemTemplate>  
<ItemTemplate><%#Eval("AssignedColor")%></ItemTemplate>  
</asp:TemplateField>

But when I view the page with loaded data and switch to Edit mode I'm getting the following error on the EditItemTemplate line: System.InvalidCastException: Specified cast is not valid.

Is there another way to bind data to the ColorPicker control?
Michael
Top achievements
Rank 1
 answered on 21 Apr 2010
0 answers
72 views
Some of our comboboxes have thousands of items. The end result is when the user clicks the drop down to expand the list of items, there is a very noticeable delay. I've tried different features like load on demand and type ahead, but they don't all work for every situation.

For example, for combo boxes that have a selected item, I'm not sure I can use load on demand. If, say, I set the combo box to load 100 at a time, but the selected item is number 300, will it cause an exception?

And type ahead helps, but the user still might click the drop down.

Any help?
e
Top achievements
Rank 2
 asked on 21 Apr 2010
2 answers
100 views
We're having a problem with the RadFileExplorer.OnClientItemSelected javascript method.  The method always gets the data for the first file item instead of the selected one.  Here is the javascript:

            function OnClientItemSelected(sender, args)
            {
               if (args.get_item().get_type() == Telerik.Web.UI.FileExplorerItemType.File)
               {
                   // if the item is a file
                   var file = ""File path : "" + args.get_item().get_path() + ""\n"";
                   file = file + ""File size : "" + args.get_item().get_size();
                   var label = $get(""" + labelClientID + @""");
                   label.innerText = file;
                   alert(""Selected file: \n"" + file);
               }
               else
               {// folder
                   alert(""The selected item is a directory"");
               }
               alert(""OnClientItemSelected : "" + (args instanceof Telerik.Web.UI.RadFileExplorerEventArgs).toString());
            }

So it seems that the args.get_item() is always selecting the first file item.  How do we fix this?  I've also attached a screenshot.  You can see the info in the label is for the first file instead of the selected one.
Ryan Fligg
Top achievements
Rank 1
 answered on 21 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?