我正在寻找样本代码, 该代码将显示如何设定 Html. Telerik (). Upload ()
函数的验证, 这样用户只能上传 .jpg
文件。 我想只支持 .jpg
文件 。
有谁有我可以利用的好例子或网站吗?
我正在寻找样本代码, 该代码将显示如何设定 Html. Telerik (). Upload ()
函数的验证, 这样用户只能上传 .jpg
文件。 我想只支持 .jpg
文件 。
有谁有我可以利用的好例子或网站吗?
不幸的是, 无法使用 < strong> Html. Telerik () 过滤扩展 。 上加() strong > 是因为浏览器执行 < code@ lt; input type= " file" / & gt; code > 的方式 。
但用 html 和 手笔来做到这一点还有别的办法:
HTML HTML
<input name="fileToUpload" type="file" onchange="check_file()" >
手笔
function check_file(){
str=document.getElementById( fileToUpload ).value.toUpperCase();
suffix=".JPG";
suffix2=".JPEG";
if(!(str.indexOf(suffix, str.length - suffix.length) !== -1||
str.indexOf(suffix2, str.length - suffix2.length) !== -1)){
alert( File type not allowed,
Allowed file: *.jpg,*.jpeg );
document.getElementById( fileToUpload ).value= ;
}
}
请见以下代码。 此代码只接受 jpeg/ jpg, png 格式图像。 图像大小也限制在 100KB 。
@(Html.Telerik().Upload()
.Name("EmployeeImageUpload")
.Multiple(false)
.Async(async => async
.Save("SaveEmployeeImage", "Employee")
.AutoUpload(false)
)
.ClientEvents(events => events
.OnLoad("onLoad")
.OnSelect("onSelect")
.OnSuccess("onSuccess")
)
)
<script type="text/javascript">
function onLoad(e) {
$(this).find("input").attr("accept", "image/jpeg,image/jpg,image/png");
}
function onSelect(e) {
if (e.files[0].size > 102400) {
alert( Image Size Should Be <= 100KB );
e.preventDefault();
return false;
}
var ext =e.files[0].extension.toLowerCase();
if ($.inArray(ext, [ .jpeg , .jpg , .png ]) == -1) {
alert( Only Supported Extension are jpeg/jpg, png );
e.preventDefault();
return false;
}
return true;
}
</script>
I ve set a RadGrid with Paging into a simple asp.net UpdatePanel, and it caused a JavaScript exception. Does anyone familiar with that problem ?
I am now looking forward to buy a component library of silverlight for increase the productivity. I find there are number of them. Telerik ComponentOne ComponentArt Infragistics Syncfusion I found ...
I have a web service which returns me some data,I am massaging this data and using this as datasource for my radgrid (telerik). The datasource is quite large, and would like to paginate it. I found ...
I have a structure that looks following Class TreeNode { public TreeNode Parent { get; } public IEnumerable<TreeNode> Children { get; } public . . . . } I want to bind this to a ...
I currently have an IQueryable of Questions. In my Question object I have and "id" and a "parentId" which can be used to create a hierarchy. Currently, I bind a RadTreeView to the IQueryable of ...
Seems like this should be easy but I must just be missing something... I have a Telerik RadGrid on a page that allows inline editing. How do I programatically put the grid into edit mode to insert ...
I am using a RadGrid (2009 Q2) with a hierarchy. Is there a way in the client api to expand all rows and vice-versa? thanks! Update: I have written a javascript function based off the api ...
I have a telerik rad grid with PageSize=10. The problem is if I have 34 items. On the last page, there will only be 4 rows. Is there a mode to force to control to render with 6 empty null rows or do I ...