在ASP中检索图像控件的值 [英] Retrieving value of an image control in ASP

查看:60
本文介绍了在ASP中检索图像控件的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp中的图像控件中获取加载图像的值?

How can I get the value of the loaded image in the image control in asp?

推荐答案

Your Slution is very simple!




void SaveImageImage()
{


        FileStream fs = File.OpenRead(Server.MapPath(Image1.ImageUrl));  //in aspx page Image ID="Image1"
        byte[] photo = new byte[fs.Length];

        for (int i = 0; i < fs.Length; i++)
        {
            photo[i] = (byte)fs.ReadByte();
        }

        fs.Close();

        File.WriteAllBytes(Server.MapPath("BarcodeImages/myImage.jpg"),photo);


        lbllabel.Text = "Saved";




}


如果你像这样添加控件

if you add control like this
<asp:Image
runat="server"
AlternateText="W3Schools" Id="img1"
ImageUrl="img_w6.gif"/>







你可以在文件后面的代码中访问类似



string s = img1.ImageUtrl;




you can access in code behind file Like

string s=img1.ImageUtrl;


这篇关于在ASP中检索图像控件的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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