我需要显示按钮以及response.write [英] i need to display button along with response.write

查看:109
本文介绍了我需要显示按钮以及response.write的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将图像文件作为二进制数据保存到数据库中,并从数据库中检索图像文件.我正在使用response.write()显示图像文件.
问题是response.write()清除了页面中的所有标签,按钮,文本框字段.但是我需要页面中的按钮来增加计数.
代码:

I am saving image file into the database as binarydata and retrieving the image file from the database. I am using response.write() to display the image file.
The problem is response.write() clearing all the label,button,textbox fields in my page.But i need button in my page to increase the count.
CODE:

protected void btnsave2_Click(object sender, EventArgs e)
       {
           imag++;
           byte[] imagebyte = new byte[FileUpload1.PostedFile.InputStream.Length + 1];
           FileUpload1.PostedFile.InputStream.Read(imagebyte, 0, imagebyte.Length);
           cmd = new MySqlCommand("Insert Into db_image (Image,ImageId) values (@imag,@imageid)", con);
           cmd.Parameters.AddWithValue("imag", imagebyte);
           cmd.Parameters.AddWithValue("imageid", imag.ToString());
           cmd.ExecuteNonQuery();


       }


protected void btnretr2_Click(object sender, EventArgs e)
       {
           cmd = new MySqlCommand("Select Image from db_image where ImageId=''" +txt_imageid.Text.Trim()+ "'' ", con);
           dr = cmd.ExecuteReader();
           while (dr.Read())
           {
               Response.BinaryWrite((byte[])dr["Image"]);


           }
       }


帮帮我.


Help me.

推荐答案

代替写给Response,您应该使用这样的对象,并且仍将标签保留在页面上(您将在其中写上计数). br/>
检查此

在ASP.NET中显示二进制图像的控件 [ ^ ]


干杯
Instead of writing to Response you should use an object like this and still keep your label on page (in which you will write the count).

Check this

Control to Display Binary Images in ASP.NET[^]


Cheers


这篇关于我需要显示按钮以及response.write的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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