本文介绍了在asp.net中的ajax异步文件上传控件中获取添加验证时出错。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当
OnClientUploadStarted
方法中的文本框为空时,不应该允许添加文件,它应该显示一条消息。
我曾尝试过以下代码,但它无效。
请帮助。
提前致谢
我的尝试:
method it should not allowed to add the file and it should display a message.
I had tried the following code but it is not working.
Kindly help.
Thanks in advance
What I have tried:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="usercpntrol.ascx.cs" Inherits="usercpntrol" %>
<script type="text/javascript">
function uploadStarted(sender,args) {
var data;
data = document.getElementById("ucattachfile_TextBox1").innerHTML;
if (data == "") {
document.getElementById("Label1").innerHTML = "text value req";
return;
}
else {
document.getElementById("Label1").innerHTML = "uploadStarted";
}
}
function test() {
}
function test2() {
}
</script>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<ajaxToolkit:AsyncFileUpload ID="AsyncFileUpload1" OnClientUploadComplete="test" OnClientUploadError="test2"
OnClientUploadStarted="uploadStarted" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
推荐答案
这篇关于在asp.net中的ajax异步文件上传控件中获取添加验证时出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!