Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Sir, i have a table that generate at run time. i want to place an image button in table cell. and when i click on that image button then a particular function will be call.how can i do it.

What I have tried:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim filename As String = "AutoFill.png"

strb.Append("")
strb.Append("")

strb.Append("")
strb.Append("")

strb.Append("")
strb.Append("
")
strb.Append("<input type='image' src='" + "../Images/" & filename + "' width='23px' height='23px' />")
strb.Append("
")

End Sub


public sub onclicked()
.
.
mycode
.
.
End Sub
Posted
Updated 10-Jun-16 16:52pm

1 solution

You cannot have it call server side code directly like that. What you can do is put an onclick="someJavaScriptFunction()" and then write some code in JS that could even call the server side.

Or, you can add a control with something like this:
C#
Image img = new Image();
img.ID = whatever
...
// then use a server side table
table.Rows[x][y].Controls.Add(img);


This is from memory, but essentially if you are going to be adding via string then you need it to be an html control, not a server side control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900