I'm creating an ASP.NET web form application that searches PDFs for text, if the PDF has that text, it returns the name of the file and the path in a text box. So far everything works but now I'm ready to take that full path and put it inside a link.
So for example, a result would be:
https:\\www.mysite.com\example1.PDF
I want to show a hyper link in the text box that is clickable and simply labeled as:
Example 1
I wonder if I made a mistake in going with ASP.NET Web Forms to do this since it only has a Text Box form control and not a rich text box. The thing is my results are being stored in a string builder so it's not like I just need one static label to be a URL.
Here is what I have:
foreach (var f in files)
{
string pdfSearchMatch = ReadPdfFile(f.File, txtBoxSearchString.Text);
if (pdfSearchMatch != null)
{
string fileNameOnly = Regex.Replace(pdfSearchMatch, @"\\\\my\.test\.site@SSL\\Home\\Sections\\PDFs\\Courses\\.+?\\.+?\\.+?\\", "");
myCommand.CommandText = "select cc.pk1 as 'pid', f.file_name as 'xid', f.link_name as 'linkname' from course_contents cc join course_main cm on cc.crsmain_pk1 = cm.pk1 join course_contents_files ccf on cc.pk1 = ccf.course_contents_pk1 join files f on ccf.files_pk1 = f.pk1 where cm.course_id = 'COM-Syllabi' and f.link_name = '"+fileNameOnly+"'";
using (SqlDataReader sqlReader = myCommand.ExecuteReader())
{
while (sqlReader.Read())
{
string rid = Regex.Replace(sqlReader["xid"].ToString(), "/xid", "rid");
string pdfHyperlink = @"https://my.test.site/Home/pid-"+sqlReader["pid"].ToString()+"-dt-content-"+rid+sqlReader["xid"].ToString();
sb.AppendLine(pdfHyperlink);
}
}
}
}
myConnection.Close();
txtBoxResults.Text = sb.ToString();
I want the results that get assigned to txtBoxResults.Text
to be clickable links.
Thanks.