如何使用vb2005代码为asp.net通过FileUpload控件显示图像 [英] how to display image by FileUpload control using vb2005 code for asp.net

查看:57
本文介绍了如何使用vb2005代码为asp.net通过FileUpload控件显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码用于在图像控件中显示图像,但无法显示图像,如何解决此问题。



受保护的Sub UploadButton_Click(发送者)作为Object,e As EventArgs)

如果FileUploadControl.HasFile那么

尝试

Dim filename As String = Path.GetFileName(FileUploadControl.FileName)

FileUploadControl.SaveAs(Server.MapPath(〜/)&filename)

temp =〜/&filename

StatusLabel。 Text =上传状态:文件已上传!

Image1.Visible = True

Image1.ImageUrl = temp

Catch ex As Exception

StatusLabel.Text =上传状态:文件无法上传。发生以下错误:+ ex.Message

结束尝试

结束如果

End Sub

解决方案

< blockquote>



无论你编写的代码是否正确,我都没有检查你的代码。可能是Path中的问题。



ex:



Image1.ImageUrl = @〜/ + YourPath;


The following code I use to show image in an image control but it can not show image,How can I solve this problem.

Protected Sub UploadButton_Click(sender As Object, e As EventArgs)
If FileUploadControl.HasFile Then
Try
Dim filename As String = Path.GetFileName(FileUploadControl.FileName)
FileUploadControl.SaveAs(Server.MapPath("~/") & filename)
temp = "~/" & filename
StatusLabel.Text = "Upload status: File uploaded!"
Image1.Visible = True
Image1.ImageUrl = temp
Catch ex As Exception
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message
End Try
End If
End Sub

解决方案

hi,

Whatever the code you written seems correct, i didn''t checked your code. may be the problem in Path.

ex:

Image1.ImageUrl = @"~/" + YourPath;


这篇关于如何使用vb2005代码为asp.net通过FileUpload控件显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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