单击“上传”按钮后,我正在检查filename。但是它是空白的,给了我错误
对象引用未设置为对象的实例
我不知道为什么我没有得到文件名,即使在上传它。
我正在上传一个.jpg图像。以下是密码:-
protected void BtnUpload_out_Click(object sender, EventArgs e)
{
string Datafile = "";
HttpPostedFile PF_File;
string Filename = ""; // filename is blank here
if (FileUpload_out.PostedFile.FileName != "") // here I get reference error
{
if (Directory.Exists(Server.MapPath("~/Transactions/FileAttachment/" + hidAttachid.Value + "/VO/" + FileUpload_out.FileName)) == false)
{
Directory.CreateDirectory(Server.MapPath("~/Transactions/FileAttachment/" + hidAttachid.Value + "/VO"));
}}发布于 2016-01-25 08:29:45
AJAX更新面板用于防止页面完全回发。使用update面板,我们可以部分回发页面。部分页面回发执行以下操作
1.提高应用程序的性能
2.减少应用程序的页面加载时间。
3.减少应用程序与服务器之间的往返时间。
4.只有网页中需要刷新的部分才能得到回发。
我们知道我们可以使用文件上传控件将文件上传到服务器。但是,如果在update面板中使用文件上传控件,那么它就不能工作。原因是文件上传控件不适用于异步回发。
将此添加到窗体标记中,然后添加触发器,如下所示
<form id="form1" runat="server" method="post" enctype="multipart/form-data" >
.....
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID = "uploadbuttonID"/>
</Triggers>
</asp:UpdatePanel>
.....https://stackoverflow.com/questions/34986386
复制相似问题