how to add imagebutton in asp.net linkButton?
10,933
Solution 1
Try the following
var linkButton = new LinkButton() {
ID = "LinkButton1"
};
linkButton.Controls.Add(new ImageButton() {
ID = "ImageButton1",
ImageUrl = "~/images/Detail.png"
});
Solution 2
if its a LinkButton, Then you dont need to add an ImageButton into it
instead it'd be much better if you do it this way
<asp:LinkButton ID="MyLinkButton" runat="server" PostBackUrl="MyLink"><img src="MyImage" alt="MyLink" /></asp:LinkButton>
Author by
Penguen
Updated on July 26, 2022Comments
-
Penguen almost 2 years
How to do that dynamically C# ?
<asp:LinkButton ID="LinkButton1" runat="Server" >Text <asp:ImageButton ID="ImageButton1" runat="Server" ImageUrl="~/images/Detail.png"></asp:ImageButton> </asp:LinkButton>
Forexample:
LinkButton lnk = new LinkButton(); lnk.Add(new ImageButton());