1

I'm trying to modify the DIV tag content on server side.

string url = "www.mypage.com";
string html = "<a href='http://www.facebook.com/sharer.php?u='"+url+" title='Submit to Facebook' target='blank'><img src='http://itprism.com/plugins/content/itpsocialbuttons/images/big/facebook.png' alt='Submit to Facebook'></a>" +
"<a href='http://twitter.com/share?text=Atlas Paving &url='" + url + " title='Submit to Twitter' target='blank'><img src='http://itprism.com/plugins/content/itpsocialbuttons/images/big/twitter.png' alt='Submit to Twitter'></a>";

divSocial.InnerHtml = html;

When i try to navigate to the appended URL i can see that the URL is not generated correctly. appended url is empty. Whats wrong here

enter image description here

2 Answers 2

6

Your closing ' is not correct. It should be closed after the url:

string html = "<a href='http://www.facebook.com/sharer.php?u=" + url + "' title= ...

A good practice to avoid such hard to find errors and to have easier to read code is to use string.Format:

string html = string.Format("<a href='http://www.facebook.com/sharer.php?u={0}' title= ...", url);
Sign up to request clarification or add additional context in comments.

Comments

1

Can you try:

string html = "<a href='http://www.facebook.com/sharer.php?u="+url+"' title='Submit to Facebook' target='blank'>

instead of:

<a href='http://www.facebook.com/sharer.php?u='"+url+" title='Submit to Facebook' target='blank'>

I think you closed your href attribute a bit too early.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.