Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
387 views
Hi All,
I am battling to get the RadUpload control working in a EditItemTemplate.
I have followed the examples, tried other solutions from the forums, but to no avail.
After stripping everything back I have the following error :
Server Error in '/' Application.
--------------------------------------------------------------------------------
  
Invalid JSON primitive: C. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
Exception Details: System.ArgumentException: Invalid JSON primitive: C.
  
Source Error: 
  
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
  
Stack Trace: 
  
  
[ArgumentException: Invalid JSON primitive: C.]
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject() +562290
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +263
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +80
   System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +44
   System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(String input) +74
   Telerik.Web.UI.RadUpload.LoadPostData(String postDataKey, NameValueCollection postCollection) +149
   Telerik.Web.UI.RadWebControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +42
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +8910120
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878
  
   
  
  
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

It must be a problem with my base understanding of the controls, since there really isn't much to my attempts.  Below I have included my stand-alone test aspx and code behind :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UploadTesting.aspx.cs"
    Inherits="Audit.Testing.UploadTesting" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function conditionalPostback(sender, eventArgs) {
                var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                if (eventArgs.get_eventTarget().match(theRegexp)) {
                    if (upload && upload.getFileInputs()[0].value != "") {
                        alert('ajax off');
                        eventArgs.EnableAjax = false;
                    }
                }
            }
  
            var upload = null;
  
            function uploadFileSelected(sender, args) {
                upload = sender;
                var uploadContainer = sender.get_element();
                var editTable = uploadContainer.parentNode.parentNode.parentNode.parentNode;
                var fileNameTextBox = editTable.rows[0].cells[1].getElementsByTagName('input')[0];
  
                fileNameTextBox.value = args.get_fileInputField().title;
            }
  
  
        </script>
    </telerik:RadCodeBlock>
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None"
            OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid1_NeedDataSource"
            OnInsertCommand="RadGrid1_InsertCommand">
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="Id">
                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="File" UniqueName="FileUploader">
                        <EditItemTemplate>
                            <telerik:RadUpload ID="FileUploader" runat="server" ControlObjectsVisibility="RemoveButtons"
                                MaxFileInputsCount="1" MaxFileSize="4000000" >
                            </telerik:RadUpload>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblFilename" runat="server" Text='<%# Eval("Filename") %>'></asp:Label>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default">
            </HeaderContextMenu>
        </telerik:RadGrid>
    </div>
    <telerik:RadAjaxManager runat="server">
    </telerik:RadAjaxManager>
    </form>
</body>
</html>

Code behind :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
  
namespace Audit.Testing
{
    public partial class UploadTesting : System.Web.UI.Page
    {
  
          
        protected DataTable TheData
        {
            get
            {
                if (Session["TheData"] == null)
                {
                    DataTable dt = new DataTable();
                    DataColumn dcFilename = new DataColumn();
                    dcFilename.ColumnName = "Filename";
                    dcFilename.DataType = System.Type.GetType("System.String");
                    dt.Columns.Add(dcFilename);
                    DataColumn dcFiledata = new DataColumn();
                    dcFiledata.ColumnName = "FileData";
                    dcFiledata.DataType = typeof(byte[]);
                    dt.Columns.Add(dcFiledata); 
                            DataColumn dcId = new DataColumn(); 
                            dcId.ColumnName = "Id"; 
                            dcId.DataType = typeof(int); 
                            dt.Columns.Add(dcId);
  
                    Session["TheData"] = dt;
                }
                return (DataTable)Session["TheData"];
                  
            }
            set
            {
                Session["TheData"] = value;
            }
        }
  
        public string GetApplicationPath()
        {
            IMSCommonLibrary.Utilities.Objects.Globals gb = new IMSCommonLibrary.Utilities.Objects.Globals();
            return gb.Get_Server_Prefix();
        }
  
        protected void Page_Load(object sender, EventArgs e)
        {
  
        }
  
        protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            RadGrid1.DataSource = TheData;
        }
  
        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem gei = e.Item as GridEditableItem;
                ((RadUpload)gei.FindControl("FileUploader")).OnClientFileSelected = "uploadFileSelected";
            }
        }
  
        protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
        {
  
        }
    }
}

Can anyone steer me in the right direction here?  I have had no success with the GridAttachmentColumn either, so please give feedback to my design as stated.  I am not able to use SQLDataSource controls for this purpose, with datasets/datatables being my only communications with the data-layer/db.
Thanks,
Steele.

*Edit* Telerik version is 2010.3.1109.40
Steele
Top achievements
Rank 1
 answered on 17 Dec 2010
3 answers
68 views
Seems like this should be so easy...

I'm defining a <TimeSlotContextMenus> tag within the body of my RadScheduler.  Within one of the functions callable from that menu, I need to be able to access the targetSlot at which the context menu actually appeared.  I tried adding a custom OnClientTimeSlotContextMenu to my page, but this function never seems to get called at all (although the context menu appears fine).  What's up?

<telerik:RadScheduler
    ID="RadSchedulerCalendarEvents"
    runat="server"
    Width="100%"
    Height="500"
    BorderStyle="None"
    BorderWidth="0"
    HoursPanelTimeFormat="h:mm tt"
    ShowFullTime="true"
    TimeSlotContextMenuSettings-EnableDefault="true"
    StartInsertingInAdvancedForm="true"
    DisplayRecurrenceActionDialogOnMove="true"
    EnableDatePicker="False"
    EnableDescriptionField="True"
    DataSourceID="SqlDataSourceEvents"
    DataKeyField="evtID"
    DataStartField="evtStartTime"
    DataEndField="evtEndTime"
    DataSubjectField="evtName"
    DataDescriptionField="evtDescription"
    DataReminderField="evtReminder"
    DataRecurrenceField="evtRecurrenceRule"
    DataRecurrenceParentKeyField="evtRecurrenceParentID"
    OnAppointmentDelete="RadSchedulerCalendarEvents_AppointmentDelete"
    OnAppointmentUpdate="RadSchedulerCalendarEvents_AppointmentUpdate"
    OnAppointmentInsert="RadSchedulerCalendarEvents_AppointmentInsert"
    OnClientAppointmentInserting="RadSchedulerCalendarEvents_OnClientAppointmentInserting"
    OnClientAppointmentEditing="RadSchedulerCalendarEvents_OnClientAppointmentEditing"
    OnClientAppointmentMoveEnd="RadSchedulerCalendarEvents_OnClientAppointmentMoveEnd"
    OnClientAppointmentResizeEnd="RadSchedulerCalendarEvents_OnClientAppointmentResizeEnd"
    >
    <AdvancedForm Modal="true" />
    <TimeSlotContextMenus>
        <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerTimeSlotContextMenu">
            <Items>
                <telerik:RadMenuItem Text="New Event" ImageUrl="/Images/Icons16x16/calendar.png" Postback="false" NavigateUrl="javascript: SwitchToCalendarEventInsertForm(null, null);" />
                <%--<telerik:RadMenuItem Text="New Recurring Event" ImageUrl="/Images/Icons16x16/recurring-event.png" NavigateUrl="javascript: alert('upmp');" />--%>
                <%--<telerik:RadMenuItem IsSeparator="true" />--%>
                <%--<telerik:RadMenuItem Text="Group by Calendar" Value="EnableGrouping" />--%>
                <telerik:RadMenuItem IsSeparator="true" />
                <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
            </Items>
        </telerik:RadSchedulerContextMenu>
    </TimeSlotContextMenus>
    <AppointmentContextMenuSettings EnableDefault="true" />
    <Localization
        ContextMenuAddAppointment="New Event"
        ContextMenuAddRecurringAppointment="New Recurring Event"
        ContextMenuEdit="Edit Event" />
</telerik:RadScheduler>
Jesse Lawler
Top achievements
Rank 1
 answered on 16 Dec 2010
1 answer
69 views
Hello, 

I want to cut the text in my columns if they exceed the column's width (to display them in a tool-tip) .
 My columns are all GridBoundColumns, ive tried to set their width on the WIDTH propriety but it didn't work.

Thanks
Cori
Top achievements
Rank 2
 answered on 16 Dec 2010
1 answer
164 views
I have a page, let's call this main.aspx. Within main.aspx I have a splitter and load content into let's say [header] frame and [content] frame. I also have a RadWindow on main.aspx that I call to open for errors.

Within the [content] frame I have a grid using a edit Template to edit rows of the grid. If an update fails I reference and open the RadWindow using a method such as this:
var op = parent;         
var oWnd = op.GetRadMessageWindow()
oWnd.moveTo(-1000,-1000) 
oWnd.add_pageLoad(OnClientLoadMsg);
oWnd.add_close(OnClientCloseMsg);          
oWnd.setUrl("RTS_Message_Window.aspx");
oWnd.show();

The problem is that none of the server-side Page events are NOT being fired. 
I can see that the content is being loaded and I can debug client side window load events but why are the server-side events not being fired? 
This used to work. I imagine this stopped working after Ajax 2009 Q3 release.
Robert
Top achievements
Rank 1
 answered on 16 Dec 2010
4 answers
171 views

Hi. Could you provide me with the localization (internationalization) keys for the tooltips in the "Next page" and "Last page" buttons and "page" and "items" labels in the footer of the RadGrid and RadFileExplorer controls?

Also I don't know whether I'm supposed to put them in "RadEditor.Dialogs.resx" or "RadGrid.Main.resx".

Thanks in advance.

Diego Pazos
Top achievements
Rank 1
 answered on 16 Dec 2010
2 answers
97 views
I am having an issue where the client-side method deleteFileInputAt() method is throwing an exception when I pass in a zero in the OnClientFileUploaded event.  It only does this in Internet Explorer.  Firefox works just fine, or at least it is not throwing an exception.  Any ideas please?

I have tried first calling the getUploadedFiles() method to check the count prior to calling the deleteFileInputAt(), but oddly I get a javascript error saying that the getUploadedFiles() method does not exist.  I am frustrated.

Here is the function I am call in the OnClientFileUploaded event.

 

 

function resumeFileUploaded(sender, args) {

 

sender.deleteFileInputAt(0);

}

Brent
Top achievements
Rank 1
 answered on 16 Dec 2010
3 answers
200 views
I have the following aspx code:
<telerik:RadComboBox ID="rcbEditProject" runat="server" SkinID="ddRegular" Width="375px" AutoPostBack="True" OnSelectedIndexChanged="rcbEditProject_SelectedIndexChanged">
</telerik:RadComboBox>

And I have this code in code behind:

 

 

 

Protected Sub rcbEditProject_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
Dim editedItem As GridEditableItem = CType(CType(o, RadComboBox).NamingContainer, GridEditableItem)
Dim rcbEditObstacle As RadComboBox = CType(editedItem.FindControl("rcbEditObstacle"), RadComboBox)
Dim rcbEditProject As RadComboBox = CType(editedItem.FindControl("rcbEditProject"), RadComboBox) rcbEditObstacle.Items.Clear()
Dim dtEditObstacle As Data.DataTable = Nothing
If rcbEditProject.SelectedValue = "" Then
Else
' I have the code to populate the child radcombo box .....

End
Sub

Problem:
My RadGrid is in RadAjax panel. In the Item data bound for Grid I am able to populate the values fine.
My problem is when I change the value in the Parent 'rcbEditProject' combo box the selected index changed EVENT IS NOT FIRED.
If I have a break in the grid item data bound procedure it DOES trigger the Break point!
The other strange thing is that when I click the 'Cancel' button (see code below) the selected index changed event is FIRED?

 

 

 

 

 

 

 

<asp:LinkButton runat="server" ID="lnkCancel" Text="Cancel" SkinID="lnkGvEditText" Font-Bold="true" CommandName="Cancel" CausesValidation="False" />

Please help?
Thanks Sanjay


 

 

 

Radoslav
Telerik team
 answered on 16 Dec 2010
6 answers
126 views
How do I keep the "Add Record" form open after a record is inserted?  Also, is there a way to have the "Add Record" form open by default?
Daniel
Telerik team
 answered on 16 Dec 2010
5 answers
176 views

I have several RadComboBox placed in the EditItemTemplate

Of a radGrid, when I changed it into the edit mode, some of the

ComboBox becomes "transparent", some of them become text
 and the user cannot select anything.

This happended occassinaly in our client site.Attached file is the screenshot.

Any ideal about this?

 

Thank you in advanced.

James Faw
Top achievements
Rank 1
 answered on 16 Dec 2010
1 answer
86 views
Hi,

I'm trying to set the default font properties of the saved content.

I've got a RadEditor control, I'm setting the default font and text color for the editor like below:
<telerik:RadEditor runat="server"  ID="RadEditor1">
          <CssFiles>
              <telerik:EditorCssFile Value="~/EditorContentArea.css" />
          </CssFiles>
        </telerik:RadEditor>
Which works fine in the editor, however, when I save the content, using RadEditor1.Content, that styling isn't kept.

How can I set the default font and text color so that it gets saved when I save the content?

Cheers,
Ola
Rumen
Telerik team
 answered on 16 Dec 2010
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?