473,624 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handling Dynamic Image buttons

3 New Member
hi...im working on asp.net with VB
i have created a database which hav fields id,name,image path
in web form i hav written code for creation of image buttons dynamically
i hav connected the form to DB and got the table into DataSet

and also i hav placed one panel which contains image and label controls

for dynamic image buttons i hav given the image URL from table only. and i hav written addHandler method to hanling events

But for every button it handling one event only....

when i click the image button which r developed dynamically.... .the panel shld show the details of that imagebutton.

---------------------------------------------------------------------------

Imports System.Data
Imports System.Data.Sql Client
Imports System.Web.UI.C ontrol
.
Partial Class Default2
Inherits System.Web.UI.P age

Dim con As New SqlConnection
Dim da As SqlClient.SqlDa taAdapter
Dim strSQL As String
Dim ds As New DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
con = New SqlConnection(" Data Source=SYSTEM23 \SQLEXPRESS;Ini tial Catalog=epo;Int egrated Security=True")
strSQL = "select * from details"
da = New SqlClient.SqlDa taAdapter(strSQ L, con)
da.Fill(ds, "details")
Dim i As Int16
Dim j As Int16
Dim counter As Int16 = 0

i = ds.Tables("deta ils").Rows.Coun t.ToString

For j = 0 To i - 1

Dim img As New ImageButton
img.ID = "imageButto n" & j


PlaceHolder1.Co ntrols.Add(img)
img.Visible = True
img.ImageUrl = ds.Tables("deta ils").Rows(j)(2 )
img.Width = 200
img.Height = 200
AddHandler img.Command, AddressOf method1

'-- Add a pair of blank spaces

Dim MySpace As New Literal
MySpace.Text = "  &n bsp; &nbsp ; "
PlaceHolder1.Co ntrols.Add(MySp ace)

'-- Add a line break
Counter += 1
If counter Mod 4 = 0 Then
Dim MyBreak As New Literal
MyBreak.Text = "<br/>"
PlaceHolder1.Co ntrols.Add(MyBr eak)

End If

Next


End Sub
Private Sub method1(ByVal Src As Object, ByVal Args As CommandEventArg s)

Panel1.Visible = True

End Sub
Jun 25 '07 #1
4 2038
dip_developer
648 Recognized Expert Contributor
hi...im working on asp.net with VB
i have created a database which hav fields id,name,image path
in web form i hav written code for creation of image buttons dynamically
i hav connected the form to DB and got the table into DataSet

and also i hav placed one panel which contains image and label controls

for dynamic image buttons i hav given the image URL from table only. and i hav written addHandler method to hanling events

But for every button it handling one event only....

when i click the image button which r developed dynamically.... .the panel shld show the details of that imagebutton.

---------------------------------------------------------------------------

Imports System.Data
Imports System.Data.Sql Client
Imports System.Web.UI.C ontrol
.
Partial Class Default2
Inherits System.Web.UI.P age

Dim con As New SqlConnection
Dim da As SqlClient.SqlDa taAdapter
Dim strSQL As String
Dim ds As New DataSet
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
con = New SqlConnection(" Data Source=SYSTEM23 \SQLEXPRESS;Ini tial Catalog=epo;Int egrated Security=True")
strSQL = "select * from details"
da = New SqlClient.SqlDa taAdapter(strSQ L, con)
da.Fill(ds, "details")
Dim i As Int16
Dim j As Int16
Dim counter As Int16 = 0

i = ds.Tables("deta ils").Rows.Coun t.ToString

For j = 0 To i - 1

Dim img As New ImageButton
img.ID = "imageButto n" & j


PlaceHolder1.Co ntrols.Add(img)
img.Visible = True
img.ImageUrl = ds.Tables("deta ils").Rows(j)(2 )
img.Width = 200
img.Height = 200
AddHandler img.Command, AddressOf method1

'-- Add a pair of blank spaces

Dim MySpace As New Literal
MySpace.Text = "&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;"
PlaceHolder1.Co ntrols.Add(MySp ace)

'-- Add a line break
Counter += 1
If counter Mod 4 = 0 Then
Dim MyBreak As New Literal
MyBreak.Text = "<br/>"
PlaceHolder1.Co ntrols.Add(MyBr eak)

End If

Next


End Sub
Private Sub method1(ByVal Src As Object, ByVal Args As CommandEventArg s)

Panel1.Visible = True

End Sub
So whats the problem?????... .You have created one Eventhandler for every button.....this event will cause method1 to be executed in every button's click....you can have the button's id ,which causing the event to fire,inside method1 and do the needful.
Jun 25 '07 #2
kenobewan
4,871 Recognized Expert Specialist
Your eventhandler can call one function which in turn call another.
Jun 25 '07 #3
vamshiv
3 New Member
ACTUALLY I WANT TO GET THE DETAILS OF PRODUCT FROM DataSet TO THE PANEL.......THI S DETAILS DEPENDS ON THE WHICH IMAGE BUTTON WE HAV CLICKED ........
SAMPLE WEB PAGE:

http://search.live.com/images/results.aspx?q= nokia&FORM=QBIR

c the above link....u can get some idea

if i run my prog i will get the page like above

if i click on any image button the selected image details should be come to panel.....

Plz help me in this

if u give mail address...i will send this project also
Jun 26 '07 #4
vamshiv
3 New Member
Plzz help me in this..........
Jun 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2708
by: JOSEPHINE ALVAREZ | last post by:
I have this code that I want to use to do a rollover. However, because the company I am doing it for is continually changing the text, I want to be able to use dynamic text to change the text on the fly, and still have the rollover work. I have taken the text off of the buttons, but cannot figure out how to do it with dynamic text using javascript and html. For example, in the columns of this row, I want to put "About...
8
2320
by: Tim Geiges | last post by:
Since I am being challenged with learning c# I figured I could pass some of the pain on to you guys :-) I have another question(this one is important for me to fix before I can get my app to Beta) My app (an image viewer) opens with a Main form with a file explorer if you open the program with the exe, but opens with the ImageView form if you double click an image file, if you want to see the Main form once the ImageView is open the...
1
1504
by: | last post by:
Hello Guys, I am rendering the server controls dynamically using XSLT but having tough time positioning them on the web form the place where I want them to be. To be precise, I have two image buttons generated dynamically, even though I arranged them in two different cells in my XSLT but still they appear side by side.
6
1794
by: Steve Caliendo | last post by:
Hi, I'm creating 5 ImageButton controls in the panel control, and I have a unique ID specified for each one. When I click on any one of them, the Page_Load executes (Of course), but how do I know which ImageButton caused the post back ? Does it get handled in the Page_Load or do I need to create a new event handler ? Thanks,
0
1058
by: Georg Fleischer | last post by:
Hello, I have the following problem. I need to insert my global image-path to an icon the EditText Property of my <asp:DataGrid> control. <asp:EditCommandColumn ButtonType="LinkButton" UpdateText='<%=ImgSrc_Update%>' CancelText='<%=ImgSrc_Cancel%>' EditText='<%=ImgSrc_Edit%>'> The problem is, that the <%= %> statements are not evaluated.
3
13735
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
3
1741
by: topmind | last post by:
I am generally new to dot.net, coming from "scriptish" web languages such as ColdFusion and Php. I have a few questions if you don't mind. First, how does one go about inserting dynamic SQL during run-time without lots of quotes? For example, adding "AND" clauses that may or may not be present based on the query criteria form. Some of the asp.net examples use the one-line append approach which
2
2701
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous 1 2 3 4 5 ... Next Last >> I have achieved the first/previous/next/last buttons quite easily as follows in the ASPX (1.1) page:
3
8519
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at run time and the number may vary, we can't statically tie to the event to a control. I'm assuming I need to dynamically add event handlers at run time, and that one method could act as the event handler, with unique event args being created for...
0
8234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8677
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.