Hi,
I have read this article that explains how to use ItemCreated to localize declarative grid column headers. I have tried doing this in Page_Load using the grid.Columns collection and it seems to work fine + it is easier to work with a GridColumn for setting HeaderText as I have access to the UniqueName and Filter Tooltip properties.
Is there any reason not to do this?
Good day,
I'm currently migrating some user controls to telerik to use the new features. One of our user controls was a image upload control. Basically it had an asp.net img object and a stardard asp.net file upload object.
I changed it for a RadBinaryImage and a RadAsyncUpload. So far, the changes have worked. But I encountered a problem. Due to the lack of validation that the old control had, users could upload any file even if it wasn't images (like pdf, .doc, etc). Of course, it was not displayed properly on the asp.img object but it didn't show any exception, just an "x" sign. With the new user control, when I'm navigating through the records in a table and the control encounters one with a byte array that doesn't correspond to an image, it throws the following exception: "ArgumentException: The provided binary data may not be valid image or may contains unknown header".
I've read several posts in the forum and I already know that this exception is thrown because of the invalid format of the file loaded and that's ok, but I wanted to take control of this error if it happens so I did the following changes in the user control (ascx):
public
void
ShowImage(
byte
[] img)
{
try
{
String strImageSessionName = String.Format(
"imagen{0}"
, imgMuestra.ClientID);
Session[strImageSessionName] = img;
imgMain.DataValue = img;
imgTooltip.DataValue = img;
imgMuestra.Style[
"cursor"
] =
"pointer"
;
this
.EnableTooltip =
true
;
}
catch
(Exception)
{
imgMain.ImageUrl =
"~/images/image_not_available.jpg"
;
imgTooltip.ImageUrl =
"~/images/image_not_available.jpg"
;
this
.EnableTooltip =
false
;
}
}
If there's any error when loading the bytes into the control I want to show instead a fixed image. The problem is that the catch block is never reached. It always do the try block entirely even if the data is in an incorrect format. The exception is thrown later in a uncontrolled manner by the form making the form crash.
What could I do to catch this error if it happens and achieve what I want? Thanks in advance for any help.
I'm new to Telerik. Quite liking the toolkit so far. I encountered some strange behavior I would like some help with.
I'm using Internet Explorer 11.0.19. This bug seems to only happen in that browser, and not on Firefox.
I have a RadEditor with the page load function to turn enable comments and tracking. The problem is after it is turned on, on page load, clicking on a dropdown toolbar item would not do anything, i.e. no dropdown options shown. Getting rid of the code seems to fix the problem, but I need to have the flexibility to turn off and on comments and tracking from code-behind, as I'd like to dynamically change the comments and tracking options depending on the logged in user.
The bug seems to only happen if the first thing I do after page load is click on the dropdown options. If I click on the RadEditor content pane, everything would work fine.
Other things I tried:
* Focus RadEditor on page load (Didn't work)
* Move the C# code of enabling the comments and track changes to RadEditor onload, and oninit (Didn't Work, still same problem)
WebForm2.aspx content:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Telerik RadEditor Bug Problem Demonstration.aspx.cs" Inherits="TelerikRadEditor.WebForm2" %><
br
><%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %><
br
><
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"server"
><
br
></
asp:Content
><
br
><
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"server"
><
br
> <
telerik:Radeditor
CssClass
=
"RadEditorCustomCSS"
runat
=
"server"
ID
=
"RadEditor"
AutoResizeHeight
=
"true"
<br> ToolsFile="EditorRibbonBar.xml" ToolbarMode="RibbonBar" StripFormattingOptions="MsWord,ConvertWordLists" ContentFilters="DefaultFilters,PdfExportFilter"><
br
> <
ImageManager
ViewPaths
=
"~/fileuploads/images"
UploadPaths
=
"~/fileuploads/images"
DeletePaths
=
"~/fileuploads/images"
EnableImageEditor
=
"true"
MaxUploadFileSize
=
"26214400"
/><
br
> <
MediaManager
ViewPaths
=
"~/fileuploads/media"
UploadPaths
=
"~/fileuploads/media"
DeletePaths
=
"~/fileuploads/media"
MaxUploadFileSize
=
"26214400"
/><
br
> <
FlashManager
ViewPaths
=
"~/fileuploads/flash"
UploadPaths
=
"~/fileuploads/flash"
DeletePaths
=
"~/fileuploads/flash"
MaxUploadFileSize
=
"26214400"
/><
br
> <
TemplateManager
ViewPaths
=
"~/fileuploads/templates"
UploadPaths
=
"~/fileuploads/templates"
DeletePaths
=
"~/fileuploads/templates"
MaxUploadFileSize
=
"26214400"
/><
br
> <
DocumentManager
ViewPaths
=
"~/fileuploads/documents"
UploadPaths
=
"~/fileuploads/documents"
DeletePaths
=
"~/fileuploads/documents"
MaxUploadFileSize
=
"26214400"
/><
br
> </
telerik:Radeditor
><
br
></
asp:Content
><
br
><
asp:Content
ID
=
"Content3"
ContentPlaceHolderID
=
"ContentPlaceHolder2"
runat
=
"server"
><
br
></
asp:Content
>
C# Code-Behind:
using System;<
br
>using System.Collections.Generic;<
br
>using System.Linq;<
br
>using System.Web;<
br
>using System.Web.UI.WebControls;<
br
><
br
>using System.IO;<
br
>using Telerik.Web.UI;<
br
>using Telerik.Web.UI.Editor.Import;<
br
>using Telerik.Windows.Documents.Flow.FormatProviders.Docx;<
br
>using Telerik.Windows.Documents.Flow.Model;<
br
>using Telerik.Windows.Documents.Flow.Model.Styles;<
br
><
br
> <
br
>namespace TelerikRadEditor<
br
>{<
br
> public partial class WebForm2 : System.Web.UI.Page<
br
> {<
br
> protected void Page_Load(object sender, EventArgs e)<
br
> {<
br
> //Validate User<
br
> //After validation, adjust the below settings accordingly...<
br
> RadEditor TRE = RadEditor;<
br
> String author = "aUser";<
br
> String userColor = "reU0";<
br
><
br
> //Note comments also uses the track change settings author and usercssid<
br
> TRE.EnableComments = true;<
br
> TRE.EnableTrackChanges = true;<
br
> TRE.TrackChangesSettings.CanAcceptTrackChanges = true;<
br
> TRE.TrackChangesSettings.Author = author;<
br
> TRE.TrackChangesSettings.UserCssId = userColor;<
br
> }<
br
> }<
br
>}
This seemed easy but I'm having trouble changing the HeaderText of a column inside of the OnExportCellFormatting event when exporting my grid to Excel.
As an example I have a column with a headerText value of "11/2013</br>Actual" and I want to change change the </br> to a newline or CR "/r/n" ? Whatever will make the header wrap and have "11/2013" above "Actual". Which is how it is displayed in the Grid.
In my tests setting the headerText inside of the OnExportCellFormatting as below does not work.
e.FormattedColumn.HeaderText = "New Header Text";
The image is a little Add png icon (from examples) and it blows it up. I can't find anywhere to make it the normal size (or force a size). ItemStyle-width or height, HeaderStyle-width or height, or what's below don't have any affect on it. See screenshot.
<MasterTableView DataMember="Devices" DataKeyNames="ArticleID" headerStyle-Font-Bold="true" AllowFilteringByColumn="true" PageSize="20" >
<Columns>
<telerik:GridButtonColumn
CommandName="InitInsert"
Text="Add a Claim for this Device"
UniqueName="AddNewClaim"
ButtonType="imageButton"
ImageUrl="../../resources/Images/AddRecord.png"> <HeaderStyle Width="1px" /><ItemStyle Width="1px" /> </telerik:GridButtonColumn>
<telerik:GridBoundColumn
SortExpression="SerialNumber"
HeaderText="Serial Number"
HeaderButtonType="TextButton"
DataField="SerialNumber"
UniqueName="SerialNumber"
HeaderStyle-Width="400"
FilterControlWidth="100"
CurrentFilterFunction="EqualTo"
AutoPostBackOnFilter="True"
AllowFiltering="True" />
<telerik:GridBoundColumn SortExpression="ArticleID" HeaderText="Article ID" HeaderButtonType="TextButton"
DataField="ArticleID" UniqueName="ArticleID" HeaderStyle-Width="800" FilterControlWidth="800" Visible="false" />
</Columns>
Hello,
I have a problem with Radcombox that is inside form template, I need that the first radcombo
This is the code aspx
<
telerik:RadGrid
runat
=
"server"
Id
=
"rgDirecciones"
AutoGenerateColumns
=
"False"
OnDeleteCommand
=
"rgDirecciones_DeleteCommand"
OnInsertCommand
=
"rgDirecciones_InsertCommand"
OnItemDataBound
=
"rgDirecciones_ItemDataBound"
OnUpdateCommand
=
"rgDirecciones_UpdateCommand"
CellSpacing
=
"-1"
GroupPanelPosition
=
"Top"
>
<
mastertableview
datakeynames
=
"IdDireccion,IdSucursal,IdEmpresa"
>
<
rowindicatorcolumn
visible
=
"False"
>
</
rowindicatorcolumn
>
<
expandcollapsecolumn
created
=
"True"
>
</
expandcollapsecolumn
>
<
Columns
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
ButtonType
=
"ImageButton"
EditImageUrl
=
"../imagenes/Edit.png"
InsertImageUrl
=
"../imagenes/Edit.png"
Exportable
=
"False"
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"IdDireccion"
UniqueName
=
"IdDireccion"
HeaderText
=
"No Dirección"
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"TipoDireccion"
UniqueName
=
"TipoDireccion"
HeaderText
=
"Tipo"
>
<
HeaderStyle
Width
=
"80px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Direccion"
UniqueName
=
"Direccion"
HeaderText
=
"Dirección"
>
<
HeaderStyle
Width
=
"200px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Referencia"
UniqueName
=
"Referencia"
HeaderText
=
"Referencia"
>
<
HeaderStyle
Width
=
"200px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Organizacion"
UniqueName
=
"Organizacion"
HeaderText
=
"Organización"
>
<
HeaderStyle
Width
=
"200px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"NombreContacto"
UniqueName
=
"NombreContacto"
HeaderText
=
"Nombre de Contacto"
>
<
HeaderStyle
Width
=
"200px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CodigoPostal"
UniqueName
=
"CodigoPostal"
HeaderText
=
"Código Postal"
>
<
HeaderStyle
Width
=
"130px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RowVersion"
UniqueName
=
"RowVersion"
Display
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"IdSucursal"
UniqueName
=
"IdSucursal"
HeaderText
=
"Sucursal"
Display
=
"False"
>
<
HeaderStyle
Width
=
"150px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Pais"
UniqueName
=
"Pais"
Display
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DivisionTerritorial"
UniqueName
=
"DivisionTerritorial"
Display
=
"False"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Desea eliminar este registro?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Eliminar"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
ImageUrl
=
"../imagenes/Delete.png"
UniqueName
=
"DeleteColumn"
Text
=
"Eliminar"
FilterControlAltText
=
"Filter DeleteColumn column"
Exportable
=
"False"
>
<
HeaderStyle
Width
=
"30px"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
editformsettings
editformtype
=
"Template"
>
<
editcolumn
filtercontrolalttext
=
"Filter EditCommandColumn1 column"
uniquename
=
"EditCommandColumn1"
>
</
editcolumn
>
<
formtemplate
>
<
table
class
=
"table table-condensed"
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbIdDireccion"
runat
=
"server"
Text
=
"No Dirección"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadNumericTextBox
ID
=
"txtIdDireccion"
runat
=
"server"
Enabled="<%# (Container is GridEditFormInsertItem) ? true : false %>"
MaxLength="2"
MaxValue="99"
MinValue="0"
Text='<%# Bind("IdDireccion") %>'
Width="80px">
<
numberformat
decimaldigits
=
"0"
groupseparator
=
""
/>
</
telerik:RadNumericTextBox
>
<
asp:RequiredFieldValidator
ID
=
"rfvIdDireccion"
runat
=
"server"
ControlToValidate
=
"txtIdDireccion"
Display
=
"Dynamic"
ErrorMessage
=
"Campo Obligatorio"
ForeColor
=
"Red"
>
</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbPaisDire"
runat
=
"server"
Text
=
"País"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadComboBox
ID
=
"cmbPais"
Runat
=
"server"
Width
=
"350px"
Height
=
"150px"
AutoPostBack
=
"True"
OnSelectedIndexChanged
=
"combo_SelectedIndexChanged"
>
</
telerik:RadComboBox
>
<
asp:RequiredFieldValidator
ID
=
"rfvcmbPais"
runat
=
"server"
Display
=
"Dynamic"
ForeColor
=
"Red"
ControlToValidate
=
"cmbPais"
ErrorMessage
=
"Campo Obligatorio"
>
</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbDivisionTerritorial"
runat
=
"server"
Text
=
"División Territorial"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadComboBox
ID
=
"cmbDivisionTerritorial"
Runat
=
"server"
Width
=
"350px"
>
</
telerik:RadComboBox
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbDireccion"
runat
=
"server"
Text
=
"Direccion"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txtDireccion"
Runat
=
"server"
MaxLength
=
"200"
Text='<%# Bind("Direccion") %>' TextMode="MultiLine" Width="350px">
<
ClientEvents
OnValueChanging
=
"removerMasDeUnEspacio"
/>
</
telerik:RadTextBox
>
<
asp:RequiredFieldValidator
ID
=
"rfvtxtDireccion"
runat
=
"server"
Display
=
"Dynamic"
ForeColor
=
"Red"
ControlToValidate
=
"txtDireccion"
ErrorMessage
=
"Campo Obligatorio"
>
</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbNombreContacto"
runat
=
"server"
Text
=
"NombreContacto"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txtNombreContacto"
Runat
=
"server"
Text='<%# Bind("NombreContacto") %>' MaxLength="100" Width="350px">
<
ClientEvents
OnValueChanging
=
"removerMasDeUnEspacio"
/>
</
telerik:RadTextBox
>
<
asp:RequiredFieldValidator
ID
=
"rfvtxtNombreContacto"
runat
=
"server"
Display
=
"Dynamic"
ForeColor
=
"Red"
ControlToValidate
=
"txtNombreContacto"
ErrorMessage
=
"Campo Obligatorio"
>
</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbOrganizacion"
runat
=
"server"
CssClass
=
"opcionales"
Text
=
"Organización"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txtOrganizacion"
Runat
=
"server"
Text='<%# Bind("Organizacion") %>'
MaxLength="100" Width="350px">
<
ClientEvents
OnValueChanging
=
"removerMasDeUnEspacio"
/>
</
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbReferencia"
runat
=
"server"
CssClass
=
"opcionales"
Text
=
"Referencia"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txtReferencia"
Runat
=
"server"
Text='<%# Bind("Referencia") %>'
MaxLength="100" Width="350px">
<
ClientEvents
OnValueChanging
=
"removerMasDeUnEspacio"
/>
</
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
style
=
"width: 150px"
>
<
asp:Label
ID
=
"lbCodigoPostal"
runat
=
"server"
CssClass
=
"opcionales"
Text
=
"CodigoPostal"
></
asp:Label
>
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txtCodigoPostal"
Runat
=
"server"
Text='<%# Bind("CodigoPostal") %>'
MaxLength="10" Width="80px">
<
ClientEvents
OnValueChanging
=
"removerMasDeUnEspacio"
/>
</
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
causesvalidation
=
"true"
CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' Text='<%# (Container is GridEditFormInsertItem) ? "Agregar" : "Guardar" %>' validationgroup="Textbox">
<
icon
primaryiconurl
=
"../imagenes/save_16x16.png"
/>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"RadButton2"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
Text
=
"Cancelar"
>
<
icon
primaryiconurl
=
"../imagenes/cancel.png"
/>
</
telerik:RadButton
>
<
asp:Label
ID
=
"Label2"
runat
=
"server"
CssClass
=
"opcionales"
Text
=
"* Opcionales"
></
asp:Label
>
</
td
>
</
tr
>
</
table
>
</
formtemplate
>
</
EditFormSettings
>
<
CommandItemTemplate
>
<
div
class
=
"col-xs-6"
>
<
asp:LinkButton
ID
=
"lbAgregarDirecciones"
runat
=
"server"
CommandName
=
"InitInsert"
Visible='<%# !rgDirecciones.MasterTableView.IsItemInserted %>'><
img
style
=
"border:2px;vertical-align:middle;"
alt
=
""
src
=
"../imagenes/AddRecord.png"
/> Agregar</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbRefrescarDirecciones"
runat
=
"server"
>
<
img
style
=
"border:2px;vertical-align:middle;"
alt
=
""
src
=
"../imagenes/Refresh.png"
/> Refrescar
</
asp:LinkButton
>
</
div
>
<
uc1:opcionesimportaciongrid
runat
=
"server"
id
=
"OpcionesImportacionGrid3"
Grid
=
"rgDirecciones"
WebForm='<%# Page.Request.RawUrl.Substring(Page.Request.RawUrl.LastIndexOf("/") + 1) %>' NombreArchivo="Direcciones"/>
</
CommandItemTemplate
>
</
mastertableview
>
</
telerik:RadGrid
>
Code
protected
void
rgDirecciones_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
//editform
{
GridEditableItem item = (GridEditableItem)e.Item;
GridEditFormItem editItem = (GridEditFormItem)e.Item;
if
(!(e.Item
is
IGridInsertItem))
{
RadComboBox comboTipoDirecciones = (RadComboBox)editItem.FindControl(
"cmbTipoDireccion"
);
comboTipoDirecciones.SelectedValue = editItem[
"TipoDireccion"
].Text;
RadComboBox comboPais = (RadComboBox)editItem.FindControl(
"cmbPais"
);
comboPais.SelectedValue = editItem[
"Pais"
].Text;
}
}
}
protected
void
combo_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
GridEditableItem editedItem = (sender
as
RadComboBox).NamingContainer
as
GridEditableItem;
GridEditFormItem item = (sender
as
RadComboBox).NamingContainer
as
GridEditFormItem;
RadComboBox comboPaises = sender
as
RadComboBox;
RadComboBox comboDivisionTerritorial = (RadComboBox)editedItem.FindControl(
"cmbDivisionTerritorial"
);
var parametrosSQL =
new
string
[] {
null
, e.Value };
DataSet ds = Clases.MetodosGlobales.ObtenerInformacionObjeto(
"ADMMDivisionesTerritoriales_get"
, parametrosSQL);
comboDivisionTerritorial.Text =
null
;
comboDivisionTerritorial.EmptyMessage =
"- Seleccione un valor -"
;
comboDivisionTerritorial.Filter = RadComboBoxFilter.StartsWith;
comboDivisionTerritorial.DataSource = ds.Tables[0];
comboDivisionTerritorial.DataTextField =
"Descripcion"
;
comboDivisionTerritorial.DataValueField =
"Divisionterritorial"
;
comboDivisionTerritorial.DataBind();
}
The problem is that when I choose value of first radcombo. I fill the second radcombo but all the page load again and I lost the value of first combo and the second combo does not show the information. All the form is blank as if I did nothing
I do not understand what is the problem.
Regards,
hi dear,
i want to thank you about this work :) because it is very well.
kindly your support to provide me with an example that print radgrid into html pages and keep the header of grid because i want this html page specific design such as this page should have an image before i put radgid elements then put some radgrid elements then put again image and repeate it again for all items in radgrid.
also i want to ask you if i have radgrid with paging, can i get elements from each page seperately.
can you support me with example of code for both two above problemsvery quickly.
Thank you a lot.
I have some Numeric Textboxes where I am using the OnValueChanging client event to do some validation and when I utilize the eventArgs.set_cancel(true) function, the value is reverted back to the old value, however the currency format is lost when I exit the field. If I reenter the field and exit again, the dollar sign will display properly.
Here is a sample of the script:
function
onValueChanging(sender, eventArgs) {
var
value = eventArgs.get_newValue();
var
txtTest = $find(
"<%= txtTest.ClientID %>"
);
if
((value < sender.get_minValue()) || (value > txtTest.get_value())) {
alert(
'Value must be a non-negative number and cannot exceed txtTest'
);
eventArgs.set_cancel(
true
);
}
}