技术开发 频道

HyperLink控件控制图片宽度高度的方法


【IT168技术文档】

  HyperLink控件控制图片宽度高度的方法及源码如下:
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load( object sender, EventArgs e ) { HyperLink3.Text = "<img border=’0’ src=’http://dotnet.aspx.cc/Images/logoSite.gif’ height=’100’ />"; Literal Literal1 = new Literal(); Literal1.Text = "<img border=’0’ src=’http://dotnet.aspx.cc/Images/logoSite.gif’ height=’100’ />"; HyperLink4.Controls.Add(Literal1); Image image = new Image(); image.Height = Unit.Pixel(100); image.ImageUrl = "http://dotnet.aspx.cc/Images/logoSite.gif"; HyperLink5.Controls.Add(image); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>HyperLink 控制图片宽度高度的几种方法</title> </head> <body> <form id="form1" runat="server"> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="http://dotnet.aspx.cc"> <img border=’0’ src=’http://dotnet.aspx.cc/Images/logoSite.gif’ height=’100’ /></asp:HyperLink> <br /> <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="http://dotnet.aspx.cc" Text="<img border=’0’ src=’http://dotnet.aspx.cc/Images/logoSite.gif’ height=’100’ />"></asp:HyperLink> <br /> <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="http://dotnet.aspx.cc"></asp:HyperLink> <br /> <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="http://dotnet.aspx.cc"></asp:HyperLink>
<br /> <asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="http://dotnet.aspx.cc"></asp:HyperLink> <br /> <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="http://dotnet.aspx.cc"> <asp:Image ImageUrl = "http://dotnet.aspx.cc/Images/logoSite.gif" runat="server" Height="100" /> </asp:HyperLink> </div> </form> </body> </html>
0
相关文章