Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
hi guys,

First,I create buttons dynamically and its succeeded...
My code;
VB
Dim btn As Button = New Button
        btn.Text = "hello"
        btn.ID = "btnhello"


Then i need to add image on it,so far i am not able to do it with normal button, but i succeeded with image button
My Code;
VB
Dim mybutton As ImageButton = New ImageButton
       mybutton.ID = "btn1"
       mybutton.ImageUrl = "~/images.jpg"


but, i can not add text on it...

i add these buttons in to "Panel"
My Code;
VB
Panel1.Controls.Add(mybutton)


My question is, How to add image and text on button Dynamically?

Following coding are not work for me;
VB
// Positon
myButton.Left = 100 //btn.Left=100//error saying Left is not a member "System.web.ui.webcontrols.button"
myButton.Top = 100 //btn.Top=100//error saying Top is not a member "System.web.ui.webcontrols.button"

myButton.Location = new Point(Left, Top)//btn.Location=new Point(Left,Top)//error saying Location is not a member "System.web.ui.webcontrols.button"
Posted

1 solution

have you tried to set a segular button BackgroundImage val?

there's always another way...
 
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