Click here to Skip to main content
15,906,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to create dynamic imagebutton when open a new form?
Posted
Comments
AlexDpars 4-Dec-13 8:43am    
Tell us a little more about what you want to do... How dynamic?
Karthik_Mahalingam 4-Dec-13 9:14am    
Please add more info to your question..
Add some code block..

1 solution

Call this method on PageLoad()

C#
//'imageUrl' url of image
    public void CreateDynamicControl(string imageUrl)
    {
        //create object of ImageButton using new keyword
        ImageButton _imgBtn = new ImageButton();
        //set Id property of _imgBtn
        _imgBtn.ID = "ImageButton1";
        //set image url
        _imgBtn.ImageUrl = imageUrl;
        //set height & width
        _imgBtn.Height = new Unit(50);
        _imgBtn.Width = new Unit(100);
        //add ImageButton object in your form
        this.Form.Controls.Add(_imgBtn);
    }
 
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