//To validate upload control.
function
validationFailed(sender, eventArgs) {
$telerik.$(
".ErrorHolder"
).html(
""
);
$(
".ErrorHolder"
).append(
"<p>Attachment exceeding the maximum total size for the file '"
+ eventArgs.get_fileName() +
"'.</p>"
).fadeIn(
"slow"
);
}
//Remove Error Message.
function
RemoveErrorMessage(sender, eventArgs) {
$(
".ErrorHolder"
).fadeOut(
"slow"
);
}
<
telerik:RadAsyncUpload
runat
=
"server"
ID
=
"RadAsyncUpload"
MultipleFileSelection
=
"Disabled"
TemporaryFolder
=
"attachments"
TargetFolder
=
"attachments"
MaxFileSize
=
"524288"
OnFileUploaded
=
"RadAsyncUpload_FileUploaded"
OnClientValidationFailed
=
"validationFailed"
MaxFileInputsCount
=
"1"
OnClientFileUploadRemoved
=
"RemoveErrorMessage"
>
</
telerik:RadAsyncUpload
>
public
void
RadAsyncUpload_FileUploaded(
object
sender, FileUploadedEventArgs e)
{
Label fileName =
new
Label();
fileName.Text = e.File.FileName;
string
strFileName =
string
.Empty;
if
(itotalBytes < iMaxTotalBytes)
{
// Total bytes limit has not been reached, accept the file
e.IsValid =
true
;
itotalBytes += e.File.ContentLength;
}
else
{
// Limit reached, discard the file
e.IsValid =
false
;
}
if
(e.IsValid)
{
string
targetFolder = RadAsyncUpload.TargetFolder;
strFileName = e.File.FileName;
//If same file uploaded again then it will overwrite.
e.File.SaveAs(Path.Combine(Server.MapPath(targetFolder), strFileName));
}
}
It creates RadUploadTestFile file by default in attachment folder.
Why so?? Can we avoid that?
Plus it creates some wired ext file which i upload ... :(
<
telerik:RadWindow
runat
=
"server"
ID
=
"RadWindow1"
Skin
=
"Vista"
KeepInScreenBounds
=
"true"
VisibleOnPageLoad
=
"false"
Modal
=
"true"
Title
=
"Search Client"
Behaviors
=
"Close,Maximize,Move"
Width
=
"500"
Height
=
"500"
>
<
ContentTemplate
>
<
cti:ucSearchClient
ID
=
"searchClient"
runat
=
"server"
/>
</
ContentTemplate
>
</
telerik:RadWindow
>
function
openWindow() {
var
oWnd = radopen(
null
,
"RadWindow1"
);
}
Can you please let me know is there a way to open user control using radwindow and get the selected row values into the main page?
we noticed another issue that if we are using Rad Button in place of Html or ASP.net button, it is calling javascript on pageload even before we click and throws error.
var
myarray = window.dialogArguments[0];
var dd = myarray.parent.document.getElementById("ctl00_ContentBody_radComboPaymentTerms_DropDown")
dd.set_text(selectedvalue);
but this didnt work. it gives an error 'object doesn't support this prop'.
please let me know if there is any other way to solve this issue.
Hi Telerik,
I'm encountering the error below when i tried to use the arrow to in my radgrid to move the page to the next/previous page. The weird thing is when i move the page by clicking on the page number instead of the arrow im not encountering the error. Below is a sample code that recreates the error i'm encountering.
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.
ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication9.WebForm1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
Runat
=
"server"
/>
<
asp:Label
ID
=
"lbl_Notification"
runat
=
"server"
Font-Bold
=
"true"
Font-Size
=
"Large"
Text
=
"No Row right clicked"
/>
<
br
/>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"true"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
AllowSorting
=
"true"
ShowGroupPanel
=
"true"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
PageSize
=
"15"
>
<
MasterTableView
GroupLoadMode
=
"Client"
TableLayout
=
"Fixed"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"item1"
HeaderText
=
"Item1"
/>
<
telerik:GridBoundColumn
DataField
=
"item2"
HeaderText
=
"Item2"
/>
<
telerik:GridBoundColumn
DataField
=
"item3"
HeaderText
=
"Item3"
/>
<
telerik:GridBoundColumn
DataField
=
"item4"
HeaderText
=
"Item4"
/>
<
telerik:GridBoundColumn
DataField
=
"item5"
HeaderText
=
"Item5"
/>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowGroupExpandCollapse
=
"True"
ReorderColumnsOnClient
=
"True"
AllowDragToGroup
=
"True"
AllowColumnsReorder
=
"True"
EnableRowHoverStyle
=
"True"
/>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:RadGrid
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Web.UI;
using
System.Collections.ObjectModel;
namespace
WebApplication9
{
public
partial
class
WebForm1 : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
//If i remove the binding on page load the error with regards to the post back is not encountered
//when clicking the arrow and the number. However the label is not properly updated and the radcontextmenu is no longer
//available on right click after postback.
RadGrid1.Rebind();
}
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
ObservableCollection<GridItem> items =
new
ObservableCollection<GridItem>();
for
(
int
i = 0; i < 20; i++)
items.Add(
new
GridItem(i + 1));
RadGrid1.DataSource = items;
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.DataItem !=
null
&& e.Item.DataItem.GetType() ==
typeof
(GridItem))
{
var menu =
new
RadContextMenu();
menu.Targets.Add(
new
ContextMenuElementTarget() { ElementID = e.Item.ClientID, });
RadMenuItem menu1 =
new
RadMenuItem(
"Menu1"
);
menu1.Value = (e.Item.ItemIndex + 1).ToString();
menu1.Attributes[
"Column1"
] = (e.Item.DataItem
as
GridItem).item1;
RadMenuItem menu2 =
new
RadMenuItem(
"Menu2"
);
menu2.Value = (e.Item.ItemIndex + 1).ToString();
menu2.Attributes[
"Column1"
] = (e.Item.DataItem
as
GridItem).item1;
RadMenuItem menu3 =
new
RadMenuItem(
"Menu3"
);
menu3.Value = (e.Item.ItemIndex + 1).ToString();
menu3.Attributes[
"Column1"
] = (e.Item.DataItem
as
GridItem).item1;
RadMenuItem menu4 =
new
RadMenuItem(
"Menu4"
);
menu4.Value = (e.Item.ItemIndex + 1).ToString();
menu4.Attributes[
"Column1"
] = (e.Item.DataItem
as
GridItem).item1;
RadMenuItem menu5 =
new
RadMenuItem(
"Menu5"
);
RadMenuItem subItem1 =
new
RadMenuItem(
"subMenu1"
) { Value = (e.Item.ItemIndex + 1).ToString() };
subItem1.Attributes[
"Column1"
] = (e.Item.DataItem
as
GridItem).item1;
RadMenuItem subItem2 =
new
RadMenuItem(
"subMenu2"
) { Value = (e.Item.ItemIndex + 1).ToString() };
subItem2.Attributes[
"Column1"
] = (e.Item.DataItem
as
GridItem).item1;
menu5.Items.Add(subItem1);
menu5.Items.Add(subItem2);
menu.Items.Add(menu1);
menu.Items.Add(menu2);
menu.Items.Add(menu3);
menu.Items.Add(menu4);
menu.Items.Add(menu5);
menu.ItemClick +=
new
RadMenuEventHandler(menu_ItemClick);
RadGrid1.Controls.Add(menu);
}
}
void
menu_ItemClick(
object
sender, RadMenuEventArgs e)
{
lbl_Notification.Text = e.Item.Text +
"selected from the radcontextmenu for\nRow "
+ e.Item.Value +
"\n with Column1= "
+ e.Item.Attributes[
"Column1"
];
}
}
public
class
GridItem
{
public
string
item1 {
get
;
set
; }
public
string
item2 {
get
;
set
; }
public
string
item3 {
get
;
set
; }
public
string
item4 {
get
;
set
; }
public
string
item5 {
get
;
set
; }
public
GridItem(
int
rowNum)
{
item1 =
"dsadas"
+ rowNum;
item2 =
"dsadas"
+ rowNum;
item3 =
"itdsadsaem"
+ rowNum;
item4 =
"idsadsatem"
+ rowNum;
item5 =
"itedsadam"
+ rowNum;
}
}
}