读取服务器端的隐藏字段 [英] Read hidden field in server side

查看:168
本文介绍了读取服务器端的隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在客户端将值设置为hiddenfield然后我尝试读取服务器端的值。我看不懂那个价值。值始终为空字符串。你能帮助我吗?



这里我的代码:





  function  DownloadFile(control){
$( #<%= hdnSelectedFile.ClientID%> 中)VAL(control.innerHTML)。
alert( 隐藏字段值: + $( #<%= hdnSelectedFile.ClientID%>)。val())
$( #<%= btnDownloadFile.ClientID%>)。click();
}





  protected   void  btnDownloadFile_Click( object  sender,EventArgs e)
{
尝试
{
// 要获取的文件名
string fileName = hdnPreviousUploadFileNames.Value;
// 获取要下载到浏览器的文件字节
string path = Server.MapPath( @ testpath \);
byte [] fileBytes = System.IO.File.ReadAllBytes(path + fileName);
// 注意:您也可以从数据库中读取文件字节。
StreamFileToBrowser(fileName,fileBytes);
}

catch (例外情况)
{

}
}





感谢提前..

解决方案

#<%= hdnSelectedFile.ClientID%>)。val(control.innerHTML) ;
alert( 隐藏字段值: +


< blockquote>( #<%= hdnSelectedFile.ClientID%>)。val())


#<%= btnDownloadFile.ClientID%>< /跨度>)点击();
}





  protected   void  btnDownloadFile_Click( object  sender,EventArgs e)
{
尝试
{
// 要获取的文件名
string fileName = hdnPreviousUploadFileNames.Value;
// 获取要下载到浏览器的文件字节
string path = Server.MapPath( @ testpath \);
byte [] fileBytes = System.IO.File.ReadAllBytes(path + fileName);
// 注意:您也可以从数据库中读取文件字节。
StreamFileToBrowser(fileName,fileBytes);
}

catch (例外情况)
{

}
}





感谢提前..


Hello everyone,
I set value to hiddenfield in client side and then i tried to read the value in server side. I can't read that value. The value came always empty string. Can u anyone help me.

Here my code :


function DownloadFile(control) {
                   $("#<%=hdnSelectedFile.ClientID%>").val(control.innerHTML);
                   alert("hidden field value : " + $("#<%=hdnSelectedFile.ClientID%>").val())
                   $("#<%=btnDownloadFile.ClientID%>").click();
               }



protected void btnDownloadFile_Click(object sender, EventArgs e)
   {
       try
       {
           // the file name to get
           string fileName = hdnPreviousUploadFileNames.Value;
           // get the file bytes to download to the browser
           string path = Server.MapPath(@"testpath\");
           byte[] fileBytes = System.IO.File.ReadAllBytes(path + fileName);
           // NOTE: You could also read the file bytes from a database as well.
           StreamFileToBrowser(fileName, fileBytes);
       }

       catch (Exception ex)
       {

       }
   }



Thanks for Advance..

解决方案

("#<%=hdnSelectedFile.ClientID%>").val(control.innerHTML); alert("hidden field value : " +


("#<%=hdnSelectedFile.ClientID%>").val())


("#<%=btnDownloadFile.ClientID%>").click(); }



protected void btnDownloadFile_Click(object sender, EventArgs e)
   {
       try
       {
           // the file name to get
           string fileName = hdnPreviousUploadFileNames.Value;
           // get the file bytes to download to the browser
           string path = Server.MapPath(@"testpath\");
           byte[] fileBytes = System.IO.File.ReadAllBytes(path + fileName);
           // NOTE: You could also read the file bytes from a database as well.
           StreamFileToBrowser(fileName, fileBytes);
       }

       catch (Exception ex)
       {

       }
   }



Thanks for Advance..


这篇关于读取服务器端的隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆