本文介绍了如何启用使用JavaScript在fileupload中粘贴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
根据我的要求,我想使用javascript将文本框中的值粘贴到fileupload(浏览控件).但是没有机会从fileboxload(browser-Ie8)中禁用控件的文本框中粘贴值.请任何人解决我的问题.
请检查我的代码.
Hi All,
As for my requirement i want to paste the values from textbox to fileupload(browse control) using javascript.But there is no chance to paste the value from textbox that controls are disabled in fileupload(browser-Ie8).Please anybody solve my problem.
Please check my code.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<%--Scenario1--%>
<script language="javascript" type="text/javascript">
function filepath(txtval) {
document.getElementById("txtpath").value= txtval.value;
// Clear Fileupload
var textpath=document.getElementsByName('<%=UploadFile.UniqueID%>')[0];
textpath.value="";
var textpath2= textpath.cloneNode(false);
textpath2.onchange= textpath.onchange;
textpath.parentNode.replaceChild(textpath2,textpath);
}
// right click and control click disabled
// function enablecopypaste(ex){
// var message = "Cntrl key/ Right Click Option Enabled";
// // Condition to check mouse right click / Ctrl key press
// if (ex.which == 0 || ex.button == 1) {
// alert(message);
// return false;
// }
// }
</script>
<%--for size
<style type="text/css" >
.size1{width:627px}
</style>--%>
</head>
<body>
<form id="form1" runat="server">
<div>
<%--<asp:FileUpload ID="UploadFile" runat="server" onchange="filepath(this)" CssClass="size1" Width="627px"/><br />--%>
<asp:FileUpload ID="UploadFile" runat="server" OnChange="filepath(this)" Width="610px" /><br />
<asp:TextBox ID="txtpath" runat="server" Width="521px">
<%-- onKeyDown="return enablecopypaste(event)" onMouseDown="return enablecopypaste(event)">--%>
<br />
</div>
</form>
</body>
</html>
推荐答案
txtFileUploaderValue.Text = FileUploader.Value
如果缺少的值存储在视图状态变量中并设置为文本框
if your missing value then store in view state variable and set to textbox
这篇关于如何启用使用JavaScript在fileupload中粘贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!