从数据库单击图像显示数据时出现问题 [英] problem in show data from databse onclick of image

查看:77
本文介绍了从数据库单击图像显示数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好
我制作了包含图像描述(如价格明细等)的数据库
我将图片放在ASP页面上
< img src =" ...........>
当我点击数据库中的图像描述时,我想这样做
我的C#代码是

hello
i made databse that contain images description like price details etc
i place pics on asp page
<img src = "" ...........>
i want to do that when i click on image image descripton from databse comes on page
my c# code is

protected void TextBox1_TextChanged(object sender, EventArgs e)
{
    String str = "provider = Microsoft.ACE.OLEDB.12.0; Data Source = image.accdb; Persist Security Info = False;";
           OleDbConnection conn = new OleDbConnection(str);
            conn.Open();
            string sql = "SELECT * FROM image where Name = p1";
            OleDbCommand cmd = new OleDbCommand(sql, conn);
             OleDbDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
{

Session["price"] = "TextBox2.Text";

Response.Redirect("Default.aspx");


aspx页面上的代码


code on aspx page

<script type ="text/javascript">\
  function f2(value){
  document.getElementById('TextBox1').value = value;
  }
  </script>
  <style type="text/css">


          <img src = "p1.jpg"http://images.daniweb.com/vbulletin/editor/color.gif value = "p1"  onclick = "f2(value)"/>
          </td>
          <td>

              <input type = "text" id = "TextBox1"  Height="65px"
                 Width="195px"></asp:TextBox

推荐答案

首先,您共享的任何代码都与您的要求没有任何意义上的联系.

现在,
当我点击数据库中的图像描述时,我想这样做
服务器端:
步骤:
1.将onclick处理程序附加到图像
2.在服务器端,在方法中,将imageID传递给数据库并获取所需的数据
3.使用从数据库中检索到的数据来显示它

客户端:
步骤:
1.将javascript onclick处理程序附加到图像
2.使用XMLHTTPRequest在服务器端发送imageID
3.在服务器端,使用传递到数据库的imageID并获取所需的数据
4.将检索到的数据返回给客户端
5.获取Javascript中的数据并根据需要显示.

试试吧!

最后,我不知道您为什么要在服务器上单击图像以获取工具提示信息!
First of all whatever code you have shared does not make any sense-connection with what you ask.

Now,
i want to do that when i click on image image descripton from databse comes on page
SERVER side:
Steps:
1. Attach a onclick handler to the image
2. On server side, in the method, pass on the imageID to database and get the desired data
3. Use the retrieved data from database to show it

CLIENT side:
Steps:
1. Attach a javascript onclick handler to image
2. Use XMLHTTPRequest to send the imageID on server side
3. On server side, use the imageID passed to database and get the desired data
4. Return the retrieved data to client
5. Get the data in Javascript and show it as needed.

Try!

Lastly, I have no clue why would you hit a server to get a tooltip info on a click of a image!


这篇关于从数据库单击图像显示数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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