如何将图像按钮插入到链接按钮这是一个错误吗?
我尝试将图像按钮添加到链接按钮,但是下面的代码不起作用怎么办?
ImageButton _btnSave = new ImageButton();
_btnSave.ID = Guid.NewGuid().ToString();
_btnSave.AlternateText = "fsfsf";
_btnSave.Click += new ImageClickEventHandler(btnSave_Click);
_btnSave.Attributes.Add("runat", "server");
_btnSave.ImageUrl = "~/images/Ok.png";
LinkButton btnSave = new LinkButton();
btnSave.ID = Guid.NewGuid().ToString();
PlhControl.Controls.Add(_btnSave);
btnSave.Text = "Test";
btnSave.Attributes.Add("runat", "server");
btnSave.Click += new EventHandler(btnSave_Click);
PlhControl.Controls.Add(btnSave);
i try to add image button to link button but how to do that below codes not working?
ImageButton _btnSave = new ImageButton();
_btnSave.ID = Guid.NewGuid().ToString();
_btnSave.AlternateText = "fsfsf";
_btnSave.Click += new ImageClickEventHandler(btnSave_Click);
_btnSave.Attributes.Add("runat", "server");
_btnSave.ImageUrl = "~/images/Ok.png";
LinkButton btnSave = new LinkButton();
btnSave.ID = Guid.NewGuid().ToString();
PlhControl.Controls.Add(_btnSave);
btnSave.Text = "Test";
btnSave.Attributes.Add("runat", "server");
btnSave.Click += new EventHandler(btnSave_Click);
PlhControl.Controls.Add(btnSave);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应该将 ImageButton 插入 LinkButton,您应该只添加 Image 而不是。
You shouldn't insert ImageButton into LinkButton, you should just add Image instead of that.
完全没有必要将
LinkButton
插入到ImageButton
中。两个控件本质上做同样的事情;他们只是看起来不同。您可以做的是将图像放入 LinkButton 中,这基本上会使其成为
ImageButton
,除了一些关键差异(提交行为)之外:There is absolutely no need to insert a
LinkButton
into anImageButton
. Both controls essentially do the same thing; they just look different.What you can do is put an image inside of a LinkButton, which would basically make it an
ImageButton
, aside from a few key differences (submit behavior):