高分提问一个菜鸟问题(在线等待):传值问题(asp.net+c#+javascript) JS在客户端,asp.net在服务器,如果要传值,只有提交到服务器。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 asp.net中获得动态生成组件中的值//是不是这个id=file的value还是??"<input type=\"file\" id=\"file\" name=\"file\" value=\"\"> 没错,就是动态生成的那组file的value 在.aspx文件中除了动态生成的file以外,还有一些web控件这些web控件中的值比较好弄些,就是这些动态生成的不好处理本来想在一个aspx页面与aspx.cs页面间传值可是半天没捣鼓出来所以只能退而求其次传到第二个.aspx中去处理了 <script>var num=0;var Filearr=[]function ClickCreate(){ var newRow =document.all.Table1.insertRow();var newCell = newRow.insertCell();newCell.innerHTML="<input type=\"file\" id=\"file\" name=\"file\" value=\"\"> <INPUT type=\"button\" onclick=\"ClickDelete("+newRow.rowIndex+")\" name=\"delete"+newRow.rowIndex+"\" value=\"删除\"> <br>"; num++; } function ClickDelete(i) { var currRowIndex=event.srcElement.parentNode.parentNode.rowIndex; Table1.deleteRow(currRowIndex);}function f1(){var obj=document.getElementsByName("file");for(var i=0;i<obj.length;i++) { Filearr[i]=obj[i].value; } window.showModalDialog ('a.html', Filearr, 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no') ;}</script><form name=Form1><input type=button value=显示 onclick=f1() ID=Button2><input type=button value=增加 onclick=ClickCreate() ID=Button1><table id=Table1><tr><td></td></tr></table></form>/////////////////a.htm<SCRIPT>var oMyObject =[]; oMyObject=window.dialogArguments;//var sFirstName = oMyObject.firstName;//var sLastName = oMyObject.lastName;</SCRIPT> <title>Untitled</title></head><BODY STYLE="font-family: arial; font-size: 14pt; color: Snow; background-color: RosyBrown;"><SPAN STYLE="color:00ff7f"><SCRIPT></SCRIPT></SPAN><BR><SPAN STYLE="color:00ff7f"><script>for(i=0;i<oMyObject.length;i++)document.write(oMyObject[i]);document.write("<br>");</script></SPAN></BODY></HTML> 呵呵,解决了其实我就是一时马虎,忘了给form添加属性enctype="multipart/form-data"所以老是的不到aspx页面上动态产生的控件的值 private void SaveImages() { ///遍历File表单元素 HttpFileCollection files = HttpContext.Current.Request.Files; ///状态信息 System.Text.StringBuilder strMsg = new System.Text.StringBuilder(); strMsg.Append("上传的文件分别是:<hr color=red>"); for(int iFile = 0; iFile < files.Count; iFile++) { ///检查文件扩展名字 HttpPostedFile postedFile = files[iFile]; string fileName, fileExtension; fileName = System.IO.Path.GetFileName(postedFile.FileName); if (fileName != "") { fileExtension = System.IO.Path.GetExtension(fileName); strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString()+ "<br>"); strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>"); strMsg.Append("上传文件的文件名:" + fileName + "<br>"); strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>"); ///可根据扩展名字的不同保存到不同的文件夹 ///注意:可能要修改你的文件夹的匿名写入权限。 postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("file/") + fileName); } } } 100分求extjs,ext.net,extaspnet学习资料 上十万的节点,该用什么js tree? 急 IE8 中消息: 'Menu' 为空或不是对象 但是在maxthon中没有错误 大家好,帮我看看这个幻灯片如何在下面加个标题,谢谢了!急呀 怎么向iframe中注册click事件 求帮助改正确这段JS,在IE下得到的结果正常,但在Firefox下就不正确了,麻烦修改一下,谢谢! 如何按秒倒计时?(在线等待,10分钟内结贴) 事件的捕获 FCKedit如何用js对其编辑 ajax成功调用后端服务但是并没有进success也不进error 紧急求救:获得客户端动态控件的值!!!! 请教
//是不是这个id=file的value还是??
"<input type=\"file\" id=\"file\" name=\"file\" value=\"\">
这些web控件中的值比较好弄些,就是这些动态生成的不好处理
本来想在一个aspx页面与aspx.cs页面间传值可是半天没捣鼓出来
所以只能退而求其次传到第二个.aspx中去处理了
var num=0;
var Filearr=[]
function ClickCreate()
{
var newRow =document.all.Table1.insertRow();
var newCell = newRow.insertCell();
newCell.innerHTML="<input type=\"file\" id=\"file\" name=\"file\" value=\"\"> <INPUT type=\"button\" onclick=\"ClickDelete("+newRow.rowIndex+")\" name=\"delete"+newRow.rowIndex+"\" value=\"删除\"> <br>";
num++;
}
function ClickDelete(i)
{
var currRowIndex=event.srcElement.parentNode.parentNode.rowIndex;
Table1.deleteRow(currRowIndex);
}
function f1()
{var obj=document.getElementsByName("file");
for(var i=0;i<obj.length;i++)
{
Filearr[i]=obj[i].value;
}
window.showModalDialog ('a.html', Filearr, 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no') ;
}
</script>
<form name=Form1>
<input type=button value=显示 onclick=f1() ID=Button2>
<input type=button value=增加 onclick=ClickCreate() ID=Button1>
<table id=Table1>
<tr><td></td></tr>
</table>
</form>
/////////////////
a.htm
<SCRIPT>
var oMyObject =[];
oMyObject=window.dialogArguments;
//var sFirstName = oMyObject.firstName;
//var sLastName = oMyObject.lastName;
</SCRIPT>
<title>Untitled</title>
</head>
<BODY STYLE="font-family: arial; font-size: 14pt; color: Snow;
background-color: RosyBrown;">
<SPAN STYLE="color:00ff7f">
<SCRIPT></SCRIPT>
</SPAN>
<BR><SPAN STYLE="color:00ff7f">
<script>
for(i=0;i<oMyObject.length;i++)
document.write(oMyObject[i]);
document.write("<br>");
</script></SPAN>
</BODY>
</HTML>
其实我就是一时马虎,忘了给form添加属性enctype="multipart/form-data"所以老是的不到aspx页面上动态产生的控件的值
private void SaveImages()
{
///遍历File表单元素
HttpFileCollection files = HttpContext.Current.Request.Files; ///状态信息
System.Text.StringBuilder strMsg = new System.Text.StringBuilder();
strMsg.Append("上传的文件分别是:<hr color=red>");
for(int iFile = 0; iFile < files.Count; iFile++)
{
///检查文件扩展名字
HttpPostedFile postedFile = files[iFile];
string fileName, fileExtension;
fileName = System.IO.Path.GetFileName(postedFile.FileName);
if (fileName != "")
{
fileExtension = System.IO.Path.GetExtension(fileName);
strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString()+ "<br>");
strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>");
strMsg.Append("上传文件的文件名:" + fileName + "<br>");
strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>");
///可根据扩展名字的不同保存到不同的文件夹
///注意:可能要修改你的文件夹的匿名写入权限。
postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("file/") + fileName);
}
}
}