0

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");

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

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by croker10
0

samreen36,

A couple things.

First, when entering code in the comments please use the "CODE" and "/CODE" tags. It makes the code a lot easier to read for the rest of us. You can find them on the top of the text editor.

Onto your problem. I would suggest displaying your image in an asp ImageButton object. You can add postback options from there that would allow you to respond to a user click on the image.

Check out the MSDN article here for more information on ImageButtons.

Hope that helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.