Reputation: 12709
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
Upvotes: 1
Views: 174
Reputation: 83
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.
Upvotes: 1
Reputation: 93030
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);
Upvotes: 6