AjaxControlToolkit.Twitter.ActivateLinks C# (CSharp) Method

ActivateLinks() public static method

public static ActivateLinks ( string text ) : string
text string
return string
        public static string ActivateLinks(string text)
        {
            var pattern = @"(((http|https)+\:\/\/)[&#95;.a-z0-9-]+\.[a-z0-9\/&#95;:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])";
            var r = new Regex(pattern, RegexOptions.IgnoreCase);
            return r.Replace(text, "<a href=\"$1\">$1</a>");
        }

Usage Example

コード例 #1
0
            private void ctlStatus_DataBind(object sender, EventArgs e)
            {
                // set the Text property of the Label to the TotalPostCount property
                var ctlStatus = (LiteralControl)sender;
                var container = (ListViewDataItem)ctlStatus.NamingContainer;
                var status    = ((TwitterStatus)container.DataItem);

                ctlStatus.Text = String.Format(
                    "<li>{0}<br /><span class=\"ajax__twitter_createat\">{1}</span></li>",
                    Twitter.ActivateLinks(status.Text),
                    Twitter.Ago(status.CreatedAt)
                    );
            }