ASP.Net/Asp Control/Hyperlink

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

asp:HyperLink: border style and width (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
End Sub
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Creating a Basic TextBox Control</TITLE>
</HEAD>
<form runat="server">
<asp:HyperLink 
    id="hypMS"
    runat="server"
    text="Click to connect to Microsoft"
    navigateurl="http://www.microsoft.ru"
    target="_blank"
    borderwidth="7px"
    borderstyle=7
/>
</form>
</BODY>
</HTML>



asp Hyperlink button (C#)

<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
    void Page_Load()
    {
        lnkRandom.NavigateUrl = GetRandomFile();
    }
    string GetRandomFile()
    {
        string[] files = Directory.GetFiles(MapPath(Request.ApplicationPath), "*.aspx");
        Random rnd = new Random();
        string rndFile = files[rnd.Next(files.Length)];
        return Path.GetFileName(rndFile);
    }
        
</script>
<html>
<head id="Head1" runat="server">
    <title>Show HyperLink</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    <asp:HyperLink
        id="lnkRandom"
        Text="Random Link"
        Runat="server" />
    
    </div>
    </form>
</body>
</html>



asp hyperlink: font, width and text (C#)

<%@Page Language="C#"%>
<html>
<body>
<asp:hyperlink id="lnkTest" runat="server"
               navigateurl="http://www.nfex.ru"
               forecolor="red"
               backcolor="yellow"
               font-name="Times New Roman,serif"
               font-size="large"
               font-bold="true"
               width="75%"
               text="a yellow hyperlink with red text" />
</body>
</html>



asp:HyperLink with NavigateURL (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    imgMyImage.AlternateText = "Hover Text"
    imgMyImage.ImageUrl = "http://www.nfex.ru/style/logo.png"
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>HyperLink and Images Sample Page</TITLE>
</HEAD>
<BODY>
<form runat="server">
<Font Face="Tahoma" Size="+1">
<asp:HyperLink 
    id="hyp1"
    runat="server"
    Text="Click to go to www.nfex.ru"
    Target="New"
    NavigateURL="http://www.nfex.ru"
/>
<asp:HyperLink 
    id="hyp2"
    runat="server"
    Text="Click to go to Google"
    ImageURL="http://www.nfex.ru/style/logo.png"
    Target="New"
    NavigateURL="http://www.google.ru"
/>
<BR><BR>
<asp:Image 
    id="imgMyImage" 
    runat="server"
/>
</Font>
</Form>
</BODY>
</HTML>



Displaying a Graphic on a HyperLink Control (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
End Sub
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Displaying a Graphic on a HyperLink Control</TITLE>
</HEAD>
<form runat="server">
<asp:HyperLink 
    id="hypMS"
    runat="server"
    text="Click to connect to www.nfex.ru"
    imageurl="http://www.nfex.ru/style/logo.png"
    navigateurl="http://www.nfex.ru"
    target="_blank"
/>
</form>
</BODY>
</HTML>



Hyperlink: command name and url (VB.net)

<%@ Page Language="vb" %>
<html>
<head>
   <title>Action Control Example</title>
   <script runat="server">
      Sub Page_Load()
         MyButton.rumandName = "Sort"
         MyImageButton.rumandArgument = "Ascending"
         MyLinkButton.rumandName = "Filter"
         MyHyperLink.NavigateUrl = " http://www.nfex.ru/"
      End Sub
   </script>
</head>
<body>
   <h1>Action Control Example</h1>
   <form runat="server">
      <asp:table id="MyTable" border="1" cellpadding="5" cellspacing="0" runat="server">
         <asp:tablerow runat="server">
            <asp:tablecell runat="server">
               Button Control:
            </asp:tablecell>
            <asp:tablecell runat="server">
               <asp:button id="MyButton" text="Click Me!!" runat="server"/>
            </asp:tablecell>
         </asp:tablerow>
         <asp:tablerow runat="server">
            <asp:tablecell runat="server">
               ImageButton Control:
            </asp:tablecell>
            <asp:tablecell runat="server">
               <asp:imagebutton id="MyImageButton" 
                  imageurl="http://www.nfex.ru/style/logo.png" runat="Server"/>
            </asp:tablecell>
         </asp:tablerow>
         <asp:tablerow runat="server">
            <asp:tablecell runat="server">
               LinkButton Control:
            </asp:tablecell>
            <asp:tablecell runat="server">
               <asp:linkbutton id="MyLinkButton" text="Click Me" runat="server"/>
            </asp:tablecell>
         </asp:tablerow>
         <asp:tablerow runat="server">
            <asp:tablecell runat="server">
               HyperLink Control:
            </asp:tablecell>
            <asp:tablecell runat="server">
               <asp:hyperlink id="MyHyperLink" 
                  text="Click Me" 
                  navigateurl="ActionControls.aspx" 
                  target="_blank" 
                  runat="server"/>
            </asp:tablecell>
         </asp:tablerow>
      </asp:table>
   </form>
</body>
</html>