我正在使用WebControl作为WYSIWYG编辑器在Winforms .NET 4.0项目中开发 - 使用Matt Groves开发的YARTE editor。
我正在尝试添加锚标记并将href属性设置为以下路径:
var path = http://someurl.aspx?param1="val1"¶m2="val2"¶m3="youGetTheIdea"
我尝试了几种方法;当我尝试将url写入文档时,我总是得到HTML转义的&符号:
http://someurl.aspx?param1="this"&param2="doesnt"&param3="work"
我尝试过的尝试不成功:
创建链接
webBrowser.ExecCommand("CreateLink", false, path)
创建HTML并将其粘贴到:
var htmlDocument2 = args.Document.DomDocument as IHTMLDocument2;
if (htmlDocument2 == null) return;
var range = htmlDocument2.selection.createRange() as IHTMLTxtRange;
if (range == null) return;
range.pasteHTML(string.Format(path, range.text));
创建文件并将webBrowser指向它:
// assume the links are already inserted, but aren't right.
var textWithBadLinks = webBrowser.DocumentText;
var betterText = UseRegexToReplaceBadLinkText(textWithBadLinks);
using (StreamWriter outfile =new StreamWriter(@"c:\test.html"))
{
outfile.Write(betterText);
}
webBrowser.Url= new Uri(@"c:\test.html");
创建流并将webBrowser指向它:
// same as above, but instead of the URL, use the DocumentStream:
webBrowser.DocumentStream = new StreamWriter(@c:\test.html);
导航到文件:
webBrowser.Navigate(new Uri(@"c:\test.html"))
无论我选择什么方法,&符号都会逃脱链接无法正常工作。
提前感谢你的帮助。