這陣子在做HTML Editor時
使用者希望可以輸入超連結後,同時還可挑選這超連結的錨點
實作出來後,和大家分享一下 ^^
.aspx檔
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="getHtmlAnchor.aspx.cs" Inherits="getHtmlAnchor" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>未命名頁面</title>
</head>
<body>
<form id="form1" runat="server">
<div>網址:
<asp:TextBox ID="TextBox1" runat="server" Width="500px"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="取得錨點" />
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<br />
<asp:ListBox ID="ListBox1" runat="server" Rows="10" Width="500px"></asp:ListBox>
</div>
</form>
</body>
</html>
.cs檔
執行結果

原始碼下載