Jason Sypolt
Top achievements
Rank 1
Jason Sypolt
asked on 21 Sep 2010, 04:10 PM
I have a RadEditor that is used as part of a FormTemplate inside of a RadGrid. This is all inside of a telerik:RadAjaxPanel. For some reason, the Content property is always an empty string when I try to save to a database.
Here is my RadGrid:
And here are my insert and update methods:
I've read the articles about this happening in FireFox and I have set the UseSubmitBehavior property of my update button to false. The problem happens in FF, Safari, Chrome, and IE 7 and 8. I'm using the latest version of the controls and I'm working in VS 2010 on .NET 4.0.
Here is my RadGrid:
<telerik:RadGrid runat="server" ID="NewsAndViewsGrid" AutoGenerateColumns="False"
AllowPaging="True" DataSourceID="NewsAndViewsDataSource" OnUpdateCommand="Items_UpdateCommand"
OnInsertCommand="Items_InsertCommand" OnDeleteCommand="Items_DeleteCommand"
AllowSorting="True" GridLines="None" Skin="Windows7">
<ClientSettings>
<ClientEvents OnPopUpShowing="PopUpShowing" />
<Selecting AllowRowSelect="True" />
</ClientSettings>
<MasterTableView DataKeyNames="ID" DataSourceID="NewsAndViewsDataSource" CommandItemDisplay="TopAndBottom" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="PopUp">
<Columns>
<telerik:GridEditCommandColumn><ItemStyle Width="60px" /></telerik:GridEditCommandColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" ConfirmText="Are you sure you want to delete this record?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" UniqueName="column">
<ItemStyle Width="60px" />
</telerik:GridButtonColumn>
<telerik:GridDateTimeColumn DataFormatString="{0:MM/dd/yyyy}" DataField="Date" HeaderText="Date" SortExpression="Date" UniqueName="Date"></telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="Title" HeaderText="Title" SortExpression="Title" UniqueName="Title"></telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataFormatString="{0:MM/dd/yyyy}" DataField="PublicationDate" HeaderText="Publication Date" SortExpression="PublicationDate" UniqueName="PublicationDate"></telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn DataFormatString="{0:MM/dd/yyyy}" DataField="ExpirationDate" HeaderText="Expires On" SortExpression="ExpirationDate" UniqueName="ExpirationDate"></telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="Summary" HeaderText="Summary" SortExpression="Summary" UniqueName="Summary"></telerik:GridBoundColumn>
</Columns>
<EditFormSettings EditFormType="Template" PopUpSettings-Width="775">
<FormTemplate>
<table cellspacing="2" cellpadding="1" width="100%">
<tr>
<td valign="top">
<table cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><strong>Date: </strong><asp:RequiredFieldValidator ControlToValidate="Date" ID="RequiredFieldValidator1" runat="server" Font-Bold="true" ForeColor="Red" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator></td>
<td valign="top">
<telerik:RadDatePicker DbSelectedDate='<%# Bind("Date") %>' Skin="Windows7" ID="Date" runat="server" MinDate="1900-01-01">
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td valign="top"><strong>Title: </strong><asp:RequiredFieldValidator ControlToValidate="Title" ID="RequiredFieldValidator2" runat="server" Font-Bold="true" ForeColor="Red" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator></td>
<td valign="top">
<asp:TextBox ID="Title" MaxLength="100" runat="server" Text='<%# Bind( "Title" ) %>'></asp:TextBox>
</td>
</tr>
<tr>
<td valign="top"><strong>Summary: </strong><asp:RequiredFieldValidator ControlToValidate="Summary" ID="RequiredFieldValidator5" runat="server" Font-Bold="true" ForeColor="Red" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator></td>
<td valign="top">
<asp:TextBox ID="Summary" TextMode="MultiLine" Rows="4" Columns="30" MaxLength="255" runat="server" Text='<%# Bind( "Summary" ) %>'></asp:TextBox>
</td>
</tr>
<tr>
<td valign="top"><strong>Publish Date: </strong><asp:RequiredFieldValidator ControlToValidate="PublicationDate" ID="RequiredFieldValidator6" runat="server" Font-Bold="true" ForeColor="Red" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator></td>
<td valign="top">
<telerik:RadDatePicker DbSelectedDate='<%# Bind("PublicationDate") %>' Skin="Windows7" ID="PublicationDate" runat="server" MinDate="1900-01-01">
<Calendar Skin="Windows7" ID="Calendar2" RangeMinDate="1900-01-01" runat="server">
</Calendar>
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td valign="top"><strong>Expires On: </strong><asp:RequiredFieldValidator ControlToValidate="ExpirationDate" ID="RequiredFieldValidator4" runat="server" Font-Bold="true" ForeColor="Red" ErrorMessage="*" Display="Dynamic"></asp:RequiredFieldValidator></td>
<td valign="top">
<telerik:RadDatePicker DbSelectedDate='<%# Bind("ExpirationDate") %>' Skin="Windows7" ID="ExpirationDate" runat="server" MinDate="1900-01-01">
<Calendar Skin="Windows7" ID="Calendar3" RangeMinDate="1900-01-01" runat="server">
</Calendar>
</telerik:RadDatePicker>
</td>
</tr>
</table>
</td>
<td valign="top">
<strong>Body: </strong><br />
<telerik:RadEditor Width="350" Height="300" ToolsFile="~/Scripts/ToolsFile.xml" ContentAreaCssFile="~/Styles/EditorContentAreaStyles.css" Skin="Windows7" ID="Body" runat="server" Content='<%# Bind( "Body" ) %>'></telerik:RadEditor>
</td>
</tr>
<tr>
<td align="right" colspan="2" valign="top">
<br />
<asp:Button UseSubmitBehavior="false" ID="btnUpdate" Text="Save" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
<PagerStyle Mode="NextPrevAndNumeric" />
</telerik:RadGrid>
And here are my insert and update methods:
protected void Items_UpdateCommand(object source, GridCommandEventArgs e)
{
var editableItem = ((GridEditableItem)e.Item);
var id = (int)editableItem.GetDataKeyValue("ID");
NewsAndView n = NewsAndViewsRepository.GetByID(id);
if (n != null)
{
n.Title = ((TextBox)e.Item.FindControl("Title")).Text;
n.Summary = ((TextBox)e.Item.FindControl("Summary")).Text;
n.PublicationDate = ((RadDatePicker)e.Item.FindControl("PublicationDate")).SelectedDate.Value;
n.ExpirationDate = ((RadDatePicker)e.Item.FindControl("ExpirationDate")).SelectedDate.Value;
n.Date = ((RadDatePicker)e.Item.FindControl("Date")).SelectedDate.Value;
n.Body = ((RadEditor)e.Item.FindControl("Body")).Content;
NewsAndViewsRepository.Update(n);
}
}
protected void Items_InsertCommand(object source, GridCommandEventArgs e)
{
NewsAndView n = new NewsAndView();
n.Title = ((TextBox)e.Item.FindControl("Title")).Text;
n.Summary = ((TextBox)e.Item.FindControl("Summary")).Text;
n.PublicationDate = ((RadDatePicker)e.Item.FindControl("PublicationDate")).SelectedDate.Value;
n.ExpirationDate = ((RadDatePicker)e.Item.FindControl("ExpirationDate")).SelectedDate.Value;
n.Date = ((RadDatePicker)e.Item.FindControl("Date")).SelectedDate.Value;
n.Body = ((RadEditor)e.Item.FindControl("Body")).Content;
NewsAndViewsRepository.Add(n);
}
I've read the articles about this happening in FireFox and I have set the UseSubmitBehavior property of my update button to false. The problem happens in FF, Safari, Chrome, and IE 7 and 8. I'm using the latest version of the controls and I'm working in VS 2010 on .NET 4.0.
1 Answer, 1 is accepted
0
Hi Jason,
Does your application run under .NET 4.0? If this is your case, please see the following forum thread on the matter: Editor loses its value on postback.
The problem should be fixed in the latest available internal build and will not persist in the next official Q2 2010 SP2 release.
Best regards,
Rumen
the Telerik team
Does your application run under .NET 4.0? If this is your case, please see the following forum thread on the matter: Editor loses its value on postback.
The problem should be fixed in the latest available internal build and will not persist in the next official Q2 2010 SP2 release.
Best regards,
Rumen
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
