I am using facebook api for posting to the facebook wall post.THe post is getting displayed in the wall but i am not able to show the link which redirects to the site when it is clicked.
I need to show both the post as well as the link which points the posted post.
Following is my code
string viewDetailsLink = context.Url.GetLeftPart(UriPartial.Authority).ToString();
viewDetailsLink = viewDetailsLink + "/" + "Blog" + "/Index/" + "0/" + blogPost.Id;
viewDetailsLink = "<a href='" + viewDetailsLink + "'/>" + "click here to open" +"</a>";
But the whole thing is displayed as string instead of click here to open.
How do i resolve this?
You're seeing text instead of a link because you're closing our anchor tag prematurely. Try this instead:
viewDetailsLink = "<a href='" + viewDetailsLink + "'>click here to open</a>";
Here is the issue with your code:
viewDetailsLink = "<a href='" + viewDetailsLink + "'/>" + "click here to open" +"</a>";
Shouldn't close tag here ^ ^ No need to concat ^
Your code, fixed and prettied up a bit:
string viewDetailsLink = context.Url.GetLeftPart(UriPartial.Authority).ToString();
viewDetailsLink = String.Format("{0}/Blog/Index/0/{1}", viewDetailsLink, blogPost.Id);
viewDetailsLink = String.Format("<a href='{0}'>click here to open</a>", viewDetailsLink);
Related
I wonder if I can get some help, I'm creating hyperlink on the server side for each row in the my grid.
The issue is how can I set it up to open in a new window or new tab when clicking on the hyperlink.
Please help me to modify my code so it can be open in new window/new tab.
Protected Function GenerateReportLink(ByVal inputVal)
Dim output As String = ""
Try
Dim svcs As New SystemServices
' Check for null values
If Not inputVal Is Nothing And Not String.IsNullOrEmpty(inputVal) Then
Dim URL As String = Nothing
URL = (String.Format("https://www.test.com/cgis/{0}/Reports/ShortReport.asp?/SessionID={1}&IncidentID={2}", m_User.CompanyCode, m_SessionID, m_IncidentCaseID.ToString()))
output = "<a href='" + URL + "'>Report</a>"
End If
Catch
End Try
Return output
End Function
Change:
output = "<a href='" + URL + "'>Report</a>"
to:
output = "<a href='" + URL + "' target='_blank'>Report</a>"
Source: W3 Schools
It looks like you might want to set the 'target' attribute of the hyperlink, although going from what you've written so far, I'm not 100% sure where this hyperlink is going to eventually be clicked, most modern browsers, unless the user has explicitly set the behavior as otherwise would open in a new tab I think.
Either way, this might help you http://www.w3schools.com/html/html_links.asp
just add the target='_blank' property to anchor <a> tag under your output varriable.
"<a href='" + URL + "' target='_blank'>Report</a>"
Lets say I have two applications as:
www.test.com/a
www.test.com/b
In site b, I have a page set to download a pdf file. The page is called OpenBook.aspx, when I pass the bookId in the query string, it downloads the relevant file.
Here's the code to download this file from site b, by clicking on a link:
lbl.Text = "Report book {0}
is completed and ready for view. ";
Now this works within site B, but it obviously don't work within A. Because the path is set as www.test.com/a/Processing/OpenReportBook.aspx.....
I tried using the following:
string downloadLocation = HttpContext.Current.Request.Url.Host.ToString() + "/DataCenter/Processing/OpenReportBook.aspx?ReportID=";
Label2.Text = "Report book <a href='" + downloadLocation +
+ 948 +
"'>{0}</a> is completed and ready for view. ";
But still, the path is set relative to site A, when you click it from site A.
Can someone please explain how to resolve this?
Thanks
don't use HttpContext.Current.Request.Url.Host.ToString() .
Instead give the second url in web.config as below
<appSettings>
<add key="downloadurl" value="http://www.test.com/b" />
</appsetings>
And in your .cs file replace the folowing code
string downloadLocation = HttpContext.Current.Request.Url.Host.ToString() + "/DataCenter/Processing/OpenReportBook.aspx?ReportID=";
Label2.Text = "Report book <a href='" + downloadLocation +
+ 948 +
"'>{0}</a> is completed and ready for view. ";
with
string downloadLocation = ConfigurationManager.AppSettings[downloadurl"].ToString() + "/DataCenter/Processing/OpenReportBook.aspx?ReportID=";
Label2.Text = "Report book <a href='" + downloadLocation +
+ 948 +
"'>{0}</a> is completed and ready for view. ";
i hope this may solve your problem.
How shall i write the code to embed image to email body? whats wrong?
mMailMessage.Body += Server.MapPath(#"<img src=""/Styles/Images/logo.png""");
.
You are mapping a path to a file called "<img src=""/Styles/Images/logo.png"""!
What you want to do is something like this:
mMailMessage.Body += "<img src=\"" + Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + #"/Styles/Images/logo.png" + "\"/>";
my current code is below. If you visit the root of my webpage http://evanparsons.net/ you will notice that the current page is not highlighted, however when you visit a page, it works. For testing purposes, I had it return the "myPage" value to see why it isn't working... it still returns index.aspx.
Dim pageName As String = System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath)
While DBReader.Read()
_link = _link + "<li><a href='" + (DBReader("source")) + "'"
If ((pageName) = (DBReader("source"))) Then
_link = _link + "class='current' "
End If
_link = _link + pageName
_link = _link + ">-" + (DBReader("name")) + "- </a></li>"
End While
Basically, my navigation comes from a master page that scans my database, and as it cycles through it, I want to add a css class called current.
Have you tried converting them into lower case?
If (pageName.ToLower() = (DBReader("source")).ToLower()) Then
I'm using the following as part of sending a .net 4 email. I'd like to show the reply to text as an email hyperlink but can't quite get the format correct.
nMail.Body = Description " + txtdescription.Text +
"<br />Reply to (click here):" + txtemail.Text);
Wrap the address in an anchor tag <a> to make a link. Also make sure you encode the input.
Use HttpUtility.HtmlEncode on text and Uri.EscapeUriString on links.
nMail.Body = "Description " +
HttpUtility.HtmlEncode(txtdescription.Text) +
"<br />Reply to <a href=\"mailto:" +
Uri.EscapeUriString(txtemail.Text) +
"\">" +
HttpUtility.HtmlEncode(txtemail.Text) +
"</a>");
Use the following if the e-mail address is contained in txtemail.Text. Remember to first validate the content of txtemail.Text. The output of the following is a hyperlink to an e-mail address that also contains the e-mail address as the hyperlink text.
nMail.Body = "Description " + txtdescription.Text + "<br />Reply to (click here): " + "<a href='mailto:" + txtemail.Text + "'>" + txtemail.Text + "</a>");
You can write <a href='mailto:username#example.com'>Link Text</a>.
Try this
private string BuildEmailText(string description, string replyToAddress, string replyToText)
{
return string.Format("{0} <a href='{1}'>{2}</a>", description, replyToAddress, replyToText);
}