将字符串附加到URL

cha*_*ara 1 c# asp.net url

我正在尝试修改服务器端的DIV标记内容.

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;
Run Code Online (Sandbox Code Playgroud)

当我尝试导航到附加的URL时,我可以看到URL未正确生成.附加的网址是空的.这里错了

在此输入图像描述

Pet*_*nov 6

你的收盘'不正确.它应该在url后关闭:

string html = "<a href='http://www.facebook.com/sharer.php?u=" + url + "' title= ...
Run Code Online (Sandbox Code Playgroud)

避免难以找到错误并且更容易阅读代码的好习惯是使用string.Format:

string html = string.Format("<a href='http://www.facebook.com/sharer.php?u={0}' title= ...", url);
Run Code Online (Sandbox Code Playgroud)