ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Code Snippets  >>  Programming Code  >>  Dot Net Code  >>  C Sharp Code
 
 


 

 
 ASP.NET Code interview questions  ASP.NET Code Interview Questions
 VB.NET Code interview questions  VB.NET Code Interview Questions
 C Sharp Code interview questions  C Sharp Code Interview Questions
 ADO.NET Code interview questions  ADO.NET Code Interview Questions
Question
Automatically Hyperlink URLs and E-Mail Addresses in 
ASP.NET Pages with C#
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Automatically Hyperlink URLs and E-Mail Addresses in ASP.NET Pages with C#
Answer
# 1
using System.Text.RegularExpressions;
The second step is to detect a URL:

Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",
   RegexOptions.IgnoreCase|RegexOptions.Compiled);

Here is how to detect an e-mail address:

Regex emailregex = new 
Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)",
   RegexOptions.IgnoreCase|RegexOptions.Compiled);



private void Button1_Click(object sender, System.EventArgs 
e)
{
   string strContent = InputTextBox.Text;
   Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)",
                    RegexOptions.IgnoreCase| 
RegexOptions.Compiled);
   strContent = urlregex.Replace(strContent,
                "");
   Regex emailregex = new 
Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)",
      RegexOptions.IgnoreCase| RegexOptions.Compiled);
   strContent = emailregex.Replace(strContent, "");
   lbContent.Text += ""+strContent;
}
 
Is This Answer Correct ?    0 Yes 0 No
Guest
 

 
 
 
Other C Sharp Code Interview Questions
 
  Question Asked @ Answers
 
How to Create a Treeview Menu in ASP.NET with C#?  1
How to use ASP.NET 2.0's TreeView to Display Hierarchical Data?  1
Automatically Hyperlink URLs and E-Mail Addresses in ASP.NET Pages with C#  1
Event Handling in C# Triggering a Button  1
Code for Working with Files under a Directory?  1
"c sharp" code for factorial using static variables  4
 
For more C Sharp Code Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com