Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
85 views
similar to another post on the forum, I'm receiving the error:

j is null

on the line:

var l=(j.get_allowDelete()!=null)?j.get_allowDelete():this.get_allowDelete();

This occurs when I mouse over a calendar event. I'm using radtooltip to display a tooltip with details of the event. I'm also using a custom provider (based on Exchange managed web services).

I have programmed this as a web control (.ascx) that then gets called to display on my page.

source of LiveCalendar.ascx.cs:

using System;
using System.Drawing;
using System.IO;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using CRD.LiveCalendars.Helpers;
using CRD.LiveCalendars.Models;
using CRD.LiveCalendars.Providers;
using Telerik.Web.UI;
using System.Web.UI.WebControls;
 
namespace CRD.LiveCalendars
{
    public partial class LiveCalendar : System.Web.UI.UserControl
    {
        public ViewTabs DefaultViewTab { get; set; }
 
        public string ExchangeServerName { get; set; }
        public string ExchangeMailbox { get; set; }
        public string UserName { get; set; }
        public string UserDomain { get; set; }
        public string UserPass { get; set; }
        public bool ShowViewDay { get; set; }
        public bool ShowViewWeek { get; set; }
        public bool ShowViewMonth { get; set; }
        public int CalendarWidth { get; set; }
 
        int dayStartHour { get; set; }
        public int DayStartHour
        {
            get
            {
                if (dayStartHour > 0)
                    return dayStartHour;
                else return 9;
            }
            set
            { dayStartHour = value; }
        }
 
        int dayStartMinute { get; set; }
        public int DayStartMinute
        {
            get
            {
                if (dayStartMinute > 0)
                    return dayStartMinute;
                else return 0;
            }
            set
            { dayStartMinute = value; }
        }
 
        int dayEndHour { get; set; }
        public int DayEndHour
        {
            get
            {
                if (dayEndHour > 0)
                    return dayEndHour;
                else return 17;
            }
            set
            { dayEndHour = value; }
        }
 
        int dayEndMinute { get; set; }
        public int DayEndMinute
        {
            get
            {
                if (dayEndMinute > 0)
                    return dayEndMinute;
                else return 0;
            }
            set
            { dayEndMinute = value; }
        }
 
        protected void Page_Init(object sender, EventArgs e)
        {
            string serverPath = string.Format("http://{0}/EWS/Exchange.asmx", ExchangeServerName);
 
            ExchangeProvider provider;
            try
            {
                provider = new ExchangeProvider(serverPath, UserName, UserPass, UserDomain, ExchangeMailbox);
            }
            catch (Exception)
            {
                provider = null;
            }
 
            if (provider == null)
            {
                RadScheduler1.Visible = false;
                DisplayError();
            }
            else
            {
                RadScheduler1.Provider = provider;
            }
        }
 
        private void DisplayError()
        {
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            RadScheduler1.AppointmentDataBound += new Telerik.Web.UI.AppointmentDataBoundEventHandler(RadScheduler1_AppointmentDataBound);
            RadScheduler1.AppointmentCreated += new AppointmentCreatedEventHandler(RadScheduler1_AppointmentCreated);
 
            if (!Page.IsPostBack)
                SetupCalendar();
 
            SetupWebResources();
        }
 
        private void SetupWebResources()
        {
            HtmlLink lnkCss = new HtmlLink();
            lnkCss.Attributes.Add("media", "screen");
            lnkCss.Attributes.Add("type", "text/css");
            lnkCss.Attributes.Add("rel", "Stylesheet");
 
            ////Get the name of the Web Resource.
            String resourceName = "CRD.LiveCalendars.assets.styles.LiveCalendar.css";
 
            ////Get the type of the class.
            Type resourceType = typeof(CRD.LiveCalendars.LiveCalendar);
 
            //// Get a ClientScriptManager reference from the Page class.
            ClientScriptManager cs = Page.ClientScript;
            lnkCss.Href = cs.GetWebResourceUrl(resourceType, resourceName);
            Page.Header.Controls.Add(lnkCss);
            Page.Header.Controls.AddAt(0, lnkCss);
        }
 
        private void SetupCalendar()
        {
            // show only tabs provided in xml, and only if there is more than one option
            RadScheduler1.DayView.UserSelectable = ShowViewDay;
            RadScheduler1.WeekView.UserSelectable = ShowViewWeek;
            RadScheduler1.MonthView.UserSelectable = ShowViewMonth;
 
            // there must always be at least one ViewType. the method that parses the xml settings returns "WeekView" if nothing else is provided.
            RadScheduler1.SelectedView = (SchedulerViewType)Enum.Parse(typeof(SchedulerViewType), DefaultViewTab.ToString());
 
            RadScheduler1.TimelineView.UserSelectable = false;
 
            RadScheduler1.EnableDatePicker = false;
            //RadScheduler1.TimeZoneOffset = new TimeSpan(-7, 0, 0);
            //RadScheduler1.TimeZoneOffset = new TimeSpan(-8, 0, 0);
            RadScheduler1.DayStartTime = new TimeSpan(DayStartHour, DayStartMinute, 0);
            RadScheduler1.DayEndTime = new TimeSpan(DayEndHour, DayEndMinute, 0);
 
            RadScheduler1.Width = CalendarWidth;
        }
 
        void RadScheduler1_AppointmentDataBound(object sender, Telerik.Web.UI.SchedulerEventArgs e)
        {
            Appointment a = e.Appointment;
 
            a.BackColor = ColorTranslator.FromHtml(AppointmentHelpers.ColourFromDescription(a.Description));
            a.Attributes.Add("content", AppointmentHelpers.CleanUpDescription(a.Description));
            a.CssClass = "apo";
 
            // and "lighten the load" by resetting the heavy, MS-laden description to a text only description
            // I don't think description is actually used... but it *is* serialized out into JSON and embedded
            // in the page source
            a.Description = "";// AppointmentFormatters.StripHtml(a.Description);
        }
 
        void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            if (e.Appointment.Visible)
            {
                string id = e.Appointment.ID.ToString();
 
                foreach (string domElementID in e.Appointment.DomElements)
                {
                    Telerik.Web.UI.RadToolTip tt = new RadToolTip()
                    {
                        TargetControlID = domElementID,
                        ShowEvent = ToolTipShowEvent.OnMouseOver,
                        RelativeTo = ToolTipRelativeDisplay.Element,
                        Text = BuildToolTipHtml(e.Appointment),
                        IsClientID = true,
                        ShowDelay = 0,
                        AutoCloseDelay = 0 // popup continues to be displayed as long as moused over
                    };
 
                    phDefaultHolder.Controls.Add(tt);
                }
            }
        }
 
        private string BuildToolTipHtml(Appointment appo)
        {
            string description = appo.Attributes["content"];
 
            HtmlGenericControl div = new HtmlGenericControl("div");
            div.Attributes.Add("class", "tooltip");
 
            HtmlGenericControl divApoTitle = new HtmlGenericControl("div");
            divApoTitle.Attributes.Add("class", "ToolTipAppointmentTitle");
            divApoTitle.InnerHtml = appo.Subject;
 
            HtmlGenericControl divApoTimes = new HtmlGenericControl("div");
            divApoTimes.Attributes.Add("class", "ToolTipAppointmentTimes");
            divApoTimes.InnerHtml = string.Format("{0} - {1}", appo.Start.ToLocalTime().ToString("t"), appo.End.ToLocalTime().ToString("t"));
 
            HtmlGenericControl divApoDescription = new HtmlGenericControl("div");
            divApoDescription.Attributes.Add("class", "ToolTipAppointmentDescription");
            divApoDescription.InnerHtml = description;
 
            div.Controls.Add(divApoTitle);
            div.Controls.Add(divApoTimes);
            div.Controls.Add(divApoDescription);
 
            //div.InnerHtml = description;
 
            string result = string.Empty;
            using (StringWriter sw = new StringWriter())
            {
                var writer = new System.Web.UI.HtmlTextWriter(sw);
                div.RenderControl(writer);
                result = sw.ToString();
                writer.Close();
            }
 
            return result;
        }
    }
}

any help appreciated

Jonathan
Peter
Telerik team
 answered on 08 Apr 2011
4 answers
121 views

Once again  I cannot remember how i managed to submit support ticket, it's not obvious from the interface.. :(

So, I post a problem here.
Please, confirm if this is already fixed in the newest version of Telerik Controls otherwise would be great, if you fixed this ASAP...

If I use client-side binding and have two labels, responsible for displaying some entity fields within GridTemplateColumn and one of them corresponds to field "Name" - then another one, if it contains word "Name" in it, ignores field value and instead also shows "Name" field value! :(

<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen la' ItemStyle-CssClass='la'
    HeaderText="Model" SortExpression="SVC2.CLUSTER_STATE.NAME">
    <itemtemplate>
        <asp:Label ID="Name" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-CssClass='GridHeaderGreen la' ItemStyle-CssClass='la'
    HeaderText="Group Name" SortExpression="SVC2.CLUSTER_STATE.GROUPNAME">
    <itemtemplate>
        <asp:Label ID="GroupName" runat="server" />
    </itemtemplate>
</telerik:GridTemplateColumn>

In the given case grid shows "Name" value in first and second columns! It ignores "GroupName" value, even though json data is correct!
Jesper Matthiesen
Top achievements
Rank 1
 answered on 08 Apr 2011
1 answer
62 views
Hi,

I have a radgrid that is bound on the client-side using json response.  I run into a situation where my response can return no data (i.e.
{"d":[]} )  in this case I'd like to write something like 'No data records' to the first row/cell.  
How can I do this using the client-side API?






Thx
Pavlina
Telerik team
 answered on 08 Apr 2011
3 answers
141 views
I'm using a RadAjaxManagerProxy along with a ScriptManagerProxy in a page with four RadGrids, the RadScriptManager and RadAjaxManager are in the master page, and our testers keep generating errors like this every few hours or so:

Thread information:
    Thread ID: 14
    Thread account name: NT AUTHORITY\NETWORK SERVICE
    Is impersonating: False
    Stack trace:    at System.String.ToCharArray()
   at System.Text.Encoding.GetBytes(String s)
   at Telerik.Web.UI.ScriptEntry.GetHashCode(String value)
   at Telerik.Web.UI.ScriptEntry.GetResourceNameHashes(String assemblyName)
   at Telerik.Web.UI.ScriptEntry.Deserialize(String serializedScriptEntries)
   at Telerik.Web.UI.RadScriptManager.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
 
Obviously it's hard to capture any specific event which triggers this, I suspect I'm leaking memory somewhere over time - are there any use patterns which might lead to this?

One thing I notice when looking at the code is I have some script references in the head instead of being sent through the script manager, would the Ajax manager keep re-adding them to the page on every request and eventually lead to the out of memory issue?

Rob
 
Simon
Telerik team
 answered on 08 Apr 2011
1 answer
78 views
I have a grid with AllowFilteringByColumn="true", filtering on all columns is enabled and AutoPostBackOnFilter="false" for all columns. What I would like to do is only apply the filter when a user clicks a button either in a custom CommandTemplate or outside the grid (either one will work fine). There are two problems that are stopping me:

1. How do I fire the filtering from code-behind? I know I can do it client-side but...
2. Any column that has the filter icon will fire the filtering on selecting a value.

If I can do #1, then I can disable the grid's filtering client-side and fire the filtering using the button's click event. If I cannot fire the filtering in code-behind, then is there a way of disabling the firing of a postback on choosing one of the filter choices?
Tsvetina
Telerik team
 answered on 08 Apr 2011
1 answer
108 views
I have a grid akin to the following which has as its DataSourceID a LinqDataSource:

<telerik:RadGrid ID="MyGrid" runat="server"
    AllowAutomaticInserts="false"
    AllowFilteringByColumn="true"
    AllowSorting="true"
    PageSize="15"
    ShowFooter="true"
    EnableLinqExpressions="true"
    OnUpdateCommand="MyGrid_UpdateCommand"
    OnItemDataBound="MyGrid_ItemDataBound"
    DataSourceID="MyLinqDataSource"
    >
    <PagerStyle Mode="NextPrevNumericAndAdvanced" />
    <MasterTableView AutoGenerateColumns="false" EditMode="InPlace"
        AllowFilteringByColumn="true"
        DataKeyNames="Id"
        OverrideDataSourceControlSorting="true"
        Width="1700px" TableLayout="Fixed"
        CommandItemDisplay="Top"
        >
        <CommandItemTemplate>
            <asp:Button ID="SearchButton" runat="server" Text="Search" Width="100px" Height="2em"
                CommandName="<%=RadGrid.FilterCommandName %>" />
        </CommandItemTemplate>
        <Columns>
            ...
        </Columns>
    </MasterTableView>
    <ClientSettings AllowColumnsReorder="true" >
        <Resizing AllowColumnResize="true" AllowResizeToFit="true" EnableRealTimeResize="true" />
    </ClientSettings>
</telerik:RadGrid>

All columns have AutoPostBackOnFilter="false" and have a SortExpression. Whenever I click the button in the CommandItemTemplate I get the following error:

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

For those that answer with "use Advanced Binding", how do I replicate all the functionality of the LinqDataSource in code-behind?
Tsvetina
Telerik team
 answered on 08 Apr 2011
2 answers
90 views
Hi,

Any help on this matter would be greatly appreciated, I have been stuck on it for a good while now.

I have a radtoolbar, I have two events handled:

OnClientButtonClicked="RadToolBar_ClientButtonClicked"
OnButtonClick="RadToolBar_ButtonClick" 

Depending on the outcome of the RadToolBar_ClientButtonClicked method (javascript) I would like to/not to handle the OnButtonClick event using the RadToolBar_ButtonClick (c#) - that is, if the client-side method returns false I would like the server-side method to just not execute (I don't even want an alternative method to run, just want it to do nothing).

I have tried the following..

OnClientButtonClicked="return RadToolBar_ClientButtonClicked()"
and
OnClientButtonClicked="return RadToolBar_ClientButtonClicked();"

...but on doing this the page simply does not load (remains blank white).

Thanks a LOT!!!

Dan
Daniel
Top achievements
Rank 1
 answered on 08 Apr 2011
0 answers
65 views

Hello
Im trying to filter the radgrid with filtertemplate. the code look's like this

<telerik:GridTemplateColumn DataField="Obraz" Resizable="false" Visible="false" UniqueName="TemplateColumn"
  AllowFiltering="true">
 <FilterTemplate>
 <telerik:RadComboBox ID="RadComboBoxCountry"  DataTextField="Text"
 DataValueField="Obraz" Height="100px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("TemplateColumn").CurrentFilterValue %>'
 runat="server" OnClientSelectedIndexChanged="CountryIndexChanged">
 <Items>
 <telerik:RadComboBoxItem Text="Bez filtra" value="1"/>
  <telerik:RadComboBoxItem Text="Pojedynczy skan" value="~/Ikony/Gify/Skan.png"/>
  <telerik:RadComboBoxItem Text="Multi skan" value="~/Ikony/Gify/SkanMulti.png"/>
  <telerik:RadComboBoxItem Text="Brak skanu" value="~/Ikony/Gify/BrakSkanu.png"/>
   <telerik:RadComboBoxItem Text="Bez filtra1" value=""/>
    </Items>
   </telerik:RadComboBox>
   <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
  <script type="text/javascript">
  function CountryIndexChanged(sender, args) {
   var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
    tableView.filter("Obraz", args.get_item().get_value(), "EqualTo");
     }
   </script>
 </telerik:RadScriptBlock>
 </FilterTemplate>
<ItemTemplate>
 <asp:Image ID="Image1" runat="server" ImageUrl="<%# bind('Obraz') %>" ForeColor="White" />
 </ItemTemplate>
 <HeaderStyle Width="199px" />
<ItemStyle Width="199px" />
 </telerik:GridTemplateColumn>

and when I change the item of combox nothig happens the items are not filterd, what can be wrong?
Tomasz
Top achievements
Rank 1
 asked on 08 Apr 2011
1 answer
73 views
Hi,
Is any way to merge two RadWindows into one RadWindow?
On the left: 1. RadWindow and on the right: 2. RadWindow.

Best reagards.
Shinu
Top achievements
Rank 2
 answered on 08 Apr 2011
25 answers
768 views
I see your demo of the new AsyncUpload control claims:

RadAsyncUpload provides client-side event called OnClientValidationFailed. It is fired when the selected file has invalid extension or its size is higher than the MaxFileSize property.

The demo, however, is validating file size on the server. Is there still a problem with client-side filesize validation, or is the demo just not configured to use it?

Thanks,

Craig
Peter Filipov
Telerik team
 answered on 08 Apr 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?