Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
160 views

I am not sure if my goal is possible with the current design of the RadGrid.

Goal:
To have a RadGrid setup so that the first 2 columns are frozen, and the remaining columns are reorderable and use the reorder animation.

Attempt 1:
Good - I can not start a drag on the first 2 columns
Bad - I can drag one of the AutoGenerated columns over the first 2 column spots and the animation shows the reorder
Good - When dropping over one of the first two columns it will revert back and not actually do the reorder.
...

<ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" ColumnsReorderMethod="Reorder"

Animation-AllowColumnReorderAnimation="true" Animation-AllowColumnRevertAnimation="true">

</ClientSettings>

<MasterTableView>

<Columns>

<telerik:GridTemplateColumn Reorderable="false"><ItemTemplate>One</ItemTemplate></telerik:GridTemplateColumn>

<telerik:GridTemplateColumn Reorderable="false"><ItemTemplate>Two</ItemTemplate></telerik:GridTemplateColumn>
...AutoGenerated Columns Here

</Columns>

</MasterTableView>

...

 

Attempt 2:
Good - I can not start a drag on the first 2 columns
Good - I can not drag one of the AutoGenerated columns over the first 2 column spots
Bad - The reorder animation is not working in this case
...

<ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" ColumnsReorderMethod="Reorder"

     Animation-AllowColumnReorderAnimation="true" Animation-AllowColumnRevertAnimation="true"
    Scrolling-AutoScroll="true" Scrolling-FrozenColumnsCount
="2" 
    Scrolling-UseStaticHeaders="true" Scrolling-SaveScrollPosition="true">

</ClientSettings>

<MasterTableView>

<Columns>

<telerik:GridTemplateColumn Reorderable="false"><ItemTemplate>One</ItemTemplate></telerik:GridTemplateColumn>

<telerik:GridTemplateColumn Reorderable="false"><ItemTemplate>Two</ItemTemplate></telerik:GridTemplateColumn>
...AutoGenerated Columns Here

</Columns>

</MasterTableView>

...

 

Any advice or ideas are greatly appreciated.
Thanks!
-Dan

Andrey
Telerik team
 answered on 06 Feb 2012
1 answer
127 views

The loading panel shows the first time.

HttpAnalyzer first time:

     
        <table id="ctl39_RadioButtonList_Goal" class="radiobuttonlist-default" border="0" style="width:100%;">
        <tr>
            <td><input id="ctl39_RadioButtonList_Goal_0" type="radio" name="ctl39$RadioButtonList_Goal" value="0" checked="checked" /><label for="ctl39_RadioButtonList_Goal_0">Трудоустройство</label></td>
        </tr><tr>
            <td><input id="ctl39_RadioButtonList_Goal_1" type="radio" name="ctl39$RadioButtonList_Goal" value="1" onclick="javascript:setTimeout('__doPostBack(\'ctl39$RadioButtonList_Goal$1\',\'\')', 0)" /><label for="ctl39_RadioButtonList_Goal_1">Практика</label></td>
        </tr>
    </table>
     
</div>|61|updatePanel|ctl39_radAjaxManagerSU|<span id="ctl39_radAjaxManager" style="display:none;"></span>|0|hiddenField|__EVENTTARGET||0|hiddenField|__EVENTARGUMENT||0|hiddenField|__LASTFOCUS||1716|hiddenField|__VIEWSTATE|/wEPDwUJNzY4NzI0NDkwD2QWAmYPZBYEAgEPZBYCZg9kFgJmD2QWAmYPFgIeC18hSXRlbUNvdW50AgIWBGYPZBYCZg8VAizQkNC90LrQtdGC0LAg0LrQsNC90LTQuNC00LDRgtCwINC+0L3Qu9Cw0LnQvQMgLSBkAgEPZBYCZg8VAhsi0J/RgNC40L7RgNCx0LDQvdC6IiDQntCQ0J4AZAIDD2QWBmYPDxYCHgdWaXNpYmxlaGQWAgICD2QWBAIDDxBkEBUJBUJsYW5rB0RlZmF1bHQQcnNmIGFkdiBjYXJvdXNlbApyc2YgYmFubmVyC3JzZiBkZWZhdWx0CHJzZiBsZWZ0DHJzZiBubyB0aXRsZQlyc2YgcmlnaHQKcnNmIHNpbXBsZRUJAjE3Ai0xAjI3AjM1AjIxAjMzAjIzAjM0AjIyFCsDCWdnZ2dnZ2dnZxYBZmQCEQ8QZGQWAWZkAgEPDxYCHwFoZGQCCQ9kFhACKA9kFgICAQ8WAh8AAgIWBAIBD2QWAmYPFQJiPHRkPjxhIGhyZWY9Ii9yL2Fib3V0L3ZhY2FuY3kvYW5rZXRhb25saW5lLyI+0JDQvdC60LXRgtCwINC60LDQvdC00LjQtNCw0YLQsCDQv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w8WAh8DAlNkFgICAQ9kFgICAQ8QZGQWAGRk|76|hiddenField|__EVENTVALIDATION|/wEWCQLuqZKrCQLtypk7AvLKmTsC/aWz1QwC65yXTQLVmKOhAQKqz5nVBgK8he+tAgKuvtzaBQ==|0|asyncPostBackControlIDs|||0|postBackControlIDs|||52|updatePanelIDs||tctl39$ctl39$PanelStartPanel,tctl39$radAjaxManagerSU|0|childUpdatePanelIDs|||50|panelsToRefreshIDs||ctl39$ctl39$PanelStartPanel,ctl39$radAjaxManagerSU|2|asyncPostBackTimeout||90|52|formAction||default.aspx?item=r%2fabout%2fvacancy%2fanketaonline|

HTTPAnalyzer second:
656|updatePanel|ctl39_ctl39_PanelStartPanel|<div id="ctl39_PanelStart">
     
        <table id="ctl39_RadioButtonList_Goal" class="radiobuttonlist-default" border="0" style="width:100%;">
        <tr>
            <td><input id="ctl39_RadioButtonList_Goal_0" type="radio" name="ctl39$RadioButtonList_Goal" value="0" checked="checked" /><label for="ctl39_RadioButtonList_Goal_0">Трудоустройство</label></td>
        </tr><tr>
            <td><input id="ctl39_RadioButtonList_Goal_1" type="radio" name="ctl39$RadioButtonList_Goal" value="1" onclick="javascript:setTimeout('__doPostBack(\'ctl39$RadioButtonList_Goal$1\',\'\')', 0)" /><label for="ctl39_RadioButtonList_Goal_1">Практика</label></td>
        </tr>
    </table>
     
</div>|0|hiddenField|__EVENTTARGET||0|hiddenField|__EVENTARGUMENT||0|hiddenField|__LASTFOCUS||1716|hiddenField|__VIEWSTATE|/wEPDwUJNzY4NzI0NDkwD2QWAmYPZBYEAgEPZBYCZg9kFgJmD2QWAmYPFgIeC18hSXRlbUNvdW50AgIWBGYPZBYCZg8VAizQkNC90LrQtdGC0LAg0LrQsNC90LTQuNC00LDRgtCwINC+0L3Qu9Cw0LnQvQMgLSBkAgEPZBYCZg8VAhsi0J/RgNC40L7RgNCx0LDQvdC6IiDQntCQ0J4AZAIDD2QWBmYPDxYCHgdWaXNpYmxlaGQWAgICD2QWBAIDDxBkE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XJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPTEyMWZhZTc4MTY1YmEzZDRkFgRmDw9kFgIfBgUJdGFiRWRpdG9yZAIBDw9kFgIfBgUNdGFiU2ltcGxlVGV4dGQCBQ8UKwACZBUCClBhZ2VWaWV3XzEKUGFnZVZpZXdfMhYCZg9kFgICAQ88KwAWABYCZg8PFgIeBFNraW4FB0RlZmF1bHRkFgJmDw8WBB4VU2hvd0NvbnRlbnREdXJpbmdMb2FkaB4ORGVzdHJveU9uQ2xvc2VoZGQCigEPZBYCAgEPDxYCHhdFbmFibGVBamF4U2tpblJlbmRlcmluZ2hkZAKqAQ8PFgIfAwJJZBYCAgEPZBYCAgEPEGRkFgBkAocCDw8WAh8DAlNkFgICAQ9kFgICAQ8QZGQWAGRk|76|hiddenField|__EVENTVALIDATION|/wEWCQLuqZKrCQLtypk7AvLKmTsC/aWz1QwC65yXTQLVmKOhAQKqz5nVBgK8he+tAgKuvtzaBQ==|0|asyncPostBackControlIDs|||0|postBackControlIDs|||52|updatePanelIDs||tctl39$ctl39$PanelStartPanel,tctl39$radAjaxManagerSU|0|childUpdatePanelIDs|||27|panelsToRefreshIDs||ctl39$ctl39$PanelStartPanel|2|asyncPostBackTimeout||90|52|formAction||default.aspx?item=r%2fabout%2fvacancy%2fanketaonline|


<%@ Control Language="C#" Inherits="Test" CodeFile="Test.ascx.cs" %>

 
<telerik:RadAjaxLoadingPanel
    ID="LoadingPanel_1"
    runat="server"
    IsSticky="false"
    BackColor="#FFFFFF"
    Transparency="15"
    InitialDelayTime="0"
>
 
</telerik:RadAjaxLoadingPanel>
 
 
    <telerik:RadAjaxManager
        ID="radAjaxManager"
        runat="server"
        RequestQueueSize="50"
        RestoreOriginalRenderDelegate="True" EnableAJAX="True">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadioButtonList_Goal">
                <UpdatedControls>
                   <telerik:AjaxUpdatedControl ControlID="PanelStart" LoadingPanelID="LoadingPanel_1" UpdatePanelRenderMode="Block" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
    <div class="ContentForm">
    <asp:Panel ID="PanelStart" runat="server" Visible="true">
        <asp:RadioButtonList
            id="RadioButtonList_Goal"
            runat="server"
            Width="100%"
            DataTextField="text"
            DataValueField="value"
            AutoPostBack="true"
            EnableViewState="False">
          
                <asp:ListItem Value="0">Трудоустройство</asp:ListItem>
                <asp:ListItem Value="1" Selected="True">Практика</asp:ListItem>
            </asp:RadioButtonList>
    </asp:Panel>
    </div>
using System;
using System.Data;
using System.Diagnostics;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.Web.UI;
using RSDN;
using System.Net;
using Telerik.Web.UI;
using System.Collections.Generic;
using System.Collections;
 
using System.Xml.Linq;
 
 
 
namespace AnketaOnline
{
 
    public partial class Test : Feedback
    {
 
 
        /// <summary>
        /// portlet title
        /// </summary>
        public override string GetPortletTitle()
        {
            return
                " AnketaOnline, Анкета по трудоустройству онлайн";
        }
    }
}
Antonio Stoilkov
Telerik team
 answered on 06 Feb 2012
1 answer
108 views
Hello,

I'm building up a grid programmatically. I add GridItemColumns by setting their TemplateColumn and FilterColumn to classes that inherit from ITemplate. I'm currently working on adding a multiselect dropdown filter template. I'm able to get the control to display, I just need help getting the javascript function to work correctly. The function fires on the checkbox "Onclick" event. If I can figure out how to access the combo box from within this javascript function, I'll be fine. 

My class that inherits ITemplate, adds the onclick event to the checkbox. I've added the onclick function to the main calling page. When the user clicks the checkbox, it's fired. The comboId is the combobox "ClientID". How can I pass a reference to this javascript function and access the combo box?? Please note, the checkbox inside the comboboxitem is the control firing this event and it's the "chk" parameter below:

My Main Page which contains the grid control:
function onCheckBoxClick(chk, comboId) {
    var text = "", values = "";
 
    var combo = $find(comboId);
 
    if (combo != null) {
        alert('Found ComboBox');
 
        var items = combo.get_items();
        if (items != null) {
            alert('Found Items');
 
            alert('Num Items: ' + items.length);
        } else {
            alert('NOT Found Items');
        }
 
 
    } else {
        alert('NOT Found ComboBox');
    }

This is the "InstantiateIn" method for the "ItemTemplate" section of the combo box. 
public void InstantiateIn(Control container)
{
    chkBox = new CheckBox();
    chkBox.ID = string.Format("msChk_{0}", Column);
 
    RadComboBoxItem item = (container as RadComboBoxItem);
    RadComboBox box = (item.Owner as RadComboBox);
 
    string _onClick = "";
    _onClick = string.Format("onCheckBoxClick({0}, {1})", "this", box.ClientID.ToString());
 
    chkBox.Attributes.Add("onclick", _onClick);
    chkBox.Text = item.Text;
 
    container.Controls.Add(chkBox);
}





Thanks,
Nathan
Top achievements
Rank 2
 answered on 06 Feb 2012
1 answer
93 views
I found that the radupload gets translated into  a series of input tags.

the input type=file is just  chilling at  position: absolute; left: 0px; top: -5000px;  

this happens while the hover over is not fired.

The problem with this is that my page is rather large and -5000 px before the upload
is some checkbox

So when i click on the checkbox a File browse fires and i'm prompted to upload
a file instead of just checking the  current checkbox. 

Is there a fix for this?  I tried hiding the input but that renders the control useless.


Bozhidar
Telerik team
 answered on 06 Feb 2012
10 answers
390 views
Hi

I have a RadGrid with Master and Detail views.  The load mode for the details view is HierarchLoadMode="ServerOnDemand".  I am binding the details view on the RadGrid DetailTableDataBind event.

I am trying to set the value of one of the detail fields to a value from the master table view but can't figure out how to get a reference to the detail row/field  being bound. 

 

Thank you for your assistance

Tracy

Private Sub rgvDataExceptions_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles rgvDataExceptions.DetailTableDataBind
        Dim SelectedRow As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
        Dim intException As Int32 = SelectedRow.GetDataKeyValue("ExceptionID")
        Dim detailTable As GridTableView = DirectCast(SelectedRow.ChildItem.NestedTableViews(0), GridTableView)
        SQLDS_DataExceptionsMessage.SelectParameters.Clear()
        SQLDS_DataExceptionsMessage.SelectParameters.Add("intExceptionId", intException)
        e.DetailTableView.DataSource = SQLDS_DataExceptionsMessage
                  'Get value from master table row
        Dim strExceptionMessage As String = SelectedRow("ExceptionMessage").Text 

            I would then like to set the bltExceptionMessage,which is a bulled list that is in a template column of the details view

        
'Dim bltMessages As BulletedList = DirectCast(SelectedRow.FindControl("bltExceptionMessage"), BulletedList)
        'Dim aryMessages As New ArrayList
  
        'aryMessages.AddRange(Split(strExceptionMessage, "~"))
        'bltMessages.DataSource = aryMessages
        'bltMessages.DataBind()
  
  
    End Sub
 

 

Andrey
Telerik team
 answered on 06 Feb 2012
3 answers
302 views
I originally posted this as a reply to a year old post.

I have a RadWindowManager with DestroyOnClose='true' but on every postback, even after closing the window theRadWindowManager's Windows collection still contains the window. I do not have VisibleOnPageLoad set. Instead, on every load, I run the following javascript.

function openPromoteWindows(RadWindowManagerId) {
    var oManager = $find(RadWindowManagerId);
    var oWindows = oManager.GetWindows();
    for (i = 0; i < oWindows.length; i++) {
        var oWindow = oWindows[i];
        oWindow.show();
        oWindow.Minimize();
        oWindow.get_popupElement().style.zIndex = 10000 + i;
    }
}

This successfully opens all the windows minimized inside a taskbar. The problem is that since closed windows are still in the Windows Collection, they reappear.

I did write some code called "OnClientClose that does successfully delete the window from the windows collection on the client side, but it doesn't persist. That code is below:

function rwmPromote_Close(sender, eventargs) {
    var rwm = $find(window['rwmPromoteId']);
    var oWindows = rwm.GetWindows();
    var i;
    for (i = 0; i < oWindows.length; i++) {
        var oWindow = oWindows[i];
        if (oWindow == sender)
            break;
    }
    if (i < oWindows.length) {
        rwm._windows.splice(i, 1);
    }
}

This code was added in desperation to try and get the information persisted to the server side. I tried setting EnableViewState to false, but as expected that makes it forget about all Windows in the Windows collection except for ones added during that postback, which means it does forget about closed windows but also forgets about minimized windows.

I am about to add a HiddenField which will contain the ClientIDs of all Windows and then I will use that server side to deduce which windows, if any, were closed. While I am hopeful this will work, I am sure it's not the way it is supposed to work.

Added later! I have implemented the HiddenField solution as follows and it works successfully, but I don't think this is the proper way to achieve my goal.

function rwmPromote_Close(sender, eventargs) {
    var rwm = $find(window['rwmPromoteId']);
    var hf = $get(window['hfWindowIdsId']);
    hf.value = '';
    var oWindows = rwm.GetWindows();
    var i;
    for (i = 0; i < oWindows.length; i++) {
        var oWindow = oWindows[i];
        if (oWindow == sender)
            break;
    }
    if (i < oWindows.length) {
        rwm._windows.splice(i, 1);
        oWindows = rwm.GetWindows();
        for (i = 0; i < oWindows.length; i++) {
            hf.value += oWindows[i].id + ',';
        }
    }
}
 
and in the code behind.

// At the conclusion of every postback
  
hfWindowIds.Value = "";
foreach (RadWindow rw in rwmPromote.Windows)
{
    hfWindowIds.Value += rw.ClientID + ',';
}
 
// And then on the ValueChanged event for the HiddenField
 
        protected void hfWindowIds_ValueChanged(object sender, EventArgs e)
        {
            char[] sep = {','};
            string[] WindowIds = ((HiddenField)sender).Value.Split(sep, StringSplitOptions.RemoveEmptyEntries);
            List<RadWindow> rwList = new List<RadWindow>();
            foreach (RadWindow rw in rwmPromote.Windows)
            {
                if (!WindowIds.Contains(rw.ClientID)) rwList.Add(rw); // No longer open client side
            }
            foreach (RadWindow rw in rwList)
                rwmPromote.Windows.Remove(rw);  // Remove each closed window
        }
    }

This is all working, but I would pre3fer to know the "correct" way to achieve my goal.

Martin

Suggestions welcomed!!
Marin Bratanov
Telerik team
 answered on 06 Feb 2012
7 answers
307 views
I am trying to horizontally align specific cells when exporting the same as their ItemStyle in the markup.  I've followed several links and have it working for Excel but PDF does not.

The ExportCellFormatting event handler does not appear to fire when exporting to PDF like it does for Excel.  I believe this event is supposed to be a replacement for the deprecated ExcelExportCellFormatting event, but I would think based off the name and the deprecation of its predecessor that this should fire for PDFs as well.

ExportCellFormatting is the only event that I've found thus far where the cell's HorizontalAlign is set (off the e.FormattedColumn.ItemStyle) -- if I check the cell's HorizontalAlign in either the ItemCreated or ItemCommand event handlers it is always HorizontalAlign.NotSet.  The PdfExporting event only exposes the raw HTML, which I can manipulate, but that is tedious.

I am able to get basic formatting to occur for PDF so long as it isn't related to checking something set in the markup.  For example, I can detect whether the ItemType is an Item or AlternatingItem and set the inline style accordingly for alternating rows, and set the basic font, font size, and header formatting.

How can I format what's exported to PDF based on the formatted columns, specifically the horizontal alignment of individual cells?  Below are code samples of what I have working so far.

    <jha:RadGrid ID="grdVendors" runat="server" DataSourceID="odsVendors"
        OnItemDataBound="grdVendors_ItemDataBound" OnItemCommand="grdVendors_ItemCommand"
        OnExportCellFormatting="grdVendors_ExportCellFormatting" OnItemCreated="grdVendors_ItemCreated" OnPdfExporting="grdVendors_PdfExporting">
        <MasterTableView DataKeyNames="VendorID">
            <Columns>
                <telerik:GridBoundColumn HeaderText="ID" DataField="VendorID" Visible="false" />
                <telerik:GridBoundColumn HeaderText="First Name" DataField="FirstName" />
                <telerik:GridBoundColumn HeaderText="Last Name" DataField="LastName" />
                <telerik:GridBoundColumn HeaderText="City" DataField="City" />
                <telerik:GridBoundColumn HeaderText="State" DataField="State" ItemStyle-HorizontalAlign="Center" />
                <telerik:GridBoundColumn UniqueName="CreatedOn" HeaderText="Created On" DataField="CreatedDateTime"
                    DataFormatString="{0:MM/dd/yyyy}" ItemStyle-HorizontalAlign="Right" />
            </Columns>
        </MasterTableView>
    </jha:RadGrid>

protected void grdVendors_ItemCommand(object sender, GridCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case RadGrid.ExportToExcelCommandName:
        case RadGrid.ExportToPdfCommandName:
            grdVendors.CssClass = "export";
            string title = "Foo";
 
            GridExportSettings settings = grdVendors.ExportSettings;
            settings.ExportOnlyData = true;
            settings.OpenInNewWindow = true;
            settings.IgnorePaging = true;
            settings.HideStructureColumns = true;
            settings.FileName = string.Format("{0} {1:yyyy-MM-dd}", title, DateTime.Now);
 
            // PDF
            settings.Pdf.DefaultFontFamily = "Tahoma";
            settings.Pdf.PageTitle = title;
            settings.Pdf.Title = title;
            settings.Pdf.AllowPrinting = true;
            settings.Pdf.AllowAdd = false;
            settings.Pdf.AllowCopy = true;
            settings.Pdf.AllowModify = false;
            settings.Pdf.PaperSize = GridPaperSize.A4;
            settings.Pdf.PageHeight = Unit.Parse("210mm");
            settings.Pdf.PageWidth = Unit.Parse("297mm");
            settings.Pdf.PageTopMargin = Unit.Parse("20mm");
            settings.Pdf.PageHeaderMargin = Unit.Parse("10mm");
            settings.Pdf.PageBottomMargin = Unit.Parse("10mm");
            settings.Pdf.PageLeftMargin = Unit.Parse("10mm");
            settings.Pdf.PageRightMargin = Unit.Parse("10mm");
            break;
    }
}
 
protected void grdVendors_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
    /// Never fires when exporting to PDF
    switch (e.FormattedColumn.ItemStyle.HorizontalAlign)
    {
        case HorizontalAlign.Left:
            e.Cell.Style["text-align"] = "left";
            break;
        case HorizontalAlign.Center:
            e.Cell.Style["text-align"] = "center";
            break;
        case HorizontalAlign.Right:
            e.Cell.Style["text-align"] = "right";
            break;
    }
 
    if (e.FormattedColumn.UniqueName == "PostalCode")
        e.Cell.Style["mso-number-format"] = @"\@";
}
 
protected void grdVendors_ItemCreated(object sender, GridItemEventArgs e)
{
    if (grdVendors.CssClass.Contains("export"))
    {
        if (e.Item is GridDataItem)
        {
            foreach (TableCell cell in e.Item.Cells)
            {
                if (e.Item.ItemType == GridItemType.AlternatingItem)
                    cell.Style["background-color"] = "#E6EFF7";
                else
                    cell.Style["background-color"] = "#FFFFFF";
            }
        }
        else if (e.Item is GridHeaderItem)
        {         
            Table table = e.Item.Parent.Parent as Table;
            table.Style["font-family"] = "Tahoma";
            table.Style["font-size"] = "8pt";
 
            foreach (TableCell cell in e.Item.Cells)
            {
                cell.Style["border-color"] = "#FFFFFF";
                cell.Style["background-color"] = "#EEEEEE";
                cell.Style["text-align"] = "left";
                cell.Style["color"] = "#274777";
                cell.Style["font-weight"] = "bold";
            }
        }
    }
}


Regards,
Tim

Andrey
Telerik team
 answered on 06 Feb 2012
3 answers
168 views
In a production environment currently we are running into an issue where when we have RadCompression enabled our AJAX calls that our RadGrids make are failing and causing our page to be unusable. 

This is only happening in the production environment and not our dev/staging.

Server Information:
Server 2008 R2
64 BIT 
IIS 7.5.7600.16385
Telerik Version: 2011.2.712.40

Event code: 3005

Event message: An unhandled exception has occurred.

Event time: 1/25/2012 9:56:43 AM

Event time (UTC): 1/25/2012 2:56:43 PM

Event ID: 234287b000864dfeadd74c5105b467c8

Event sequence: 75

Event occurrence: 1

Event detail code: 0

 

Application information:

    Application domain: /LM/W3SVC/8/ROOT-1-129719554943999466

    Trust level: Full

    Application Virtual Path: /

    Application Path: e:\inetpub\site

    Machine name: 

 

Process information:

    Process ID: 12760

    Process name: w3wp.exe

    Account name: 
 

Exception information:

    Exception type: NullReferenceException

    Exception message: Object reference not set to an instance of an object.

   at Telerik.Web.UI.RadCompression.Compress(HttpApplication application)

   at Telerik.Web.UI.RadCompression.PreRequestHandlerExecute(Object sender, EventArgs e)

   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)






I'm trying to find out if this is a known issue with a good work around.  If more information is needed please let me know.
BabaYa
Top achievements
Rank 1
 answered on 06 Feb 2012
1 answer
65 views
I am working with the RadSplitter, and I have the following requirement:

<RadSplitter>
<RadToolBar> - spans across entire width of RadSplitter
<RadPane Width="20%" />
<RadSplitBar />
<RadPane Width="80%" />
</RadSplitter>

Is it possible to have a RadToolBar span the entire length of a RadSplitter at the top, with two RadPanes below the RadToolBar?
 
- similiar to how an html table can be customized;

Thanks in advance for any insight;
Dobromir
Telerik team
 answered on 06 Feb 2012
7 answers
265 views
hi all,


I need to show confirmation when closing window. how to do ?



thanks,
benjamin
Marin Bratanov
Telerik team
 answered on 06 Feb 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?