Matt Groves が開発したYARTE エディタを使用して、WYSIWYG エディタとして WebControl を使用して、Winforms .NET 4.0 プロジェクトで開発しています。
アンカー タグを追加し、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"))
私が選択したアプローチに関係なく、アンパサンドがエスケープされ、リンクが機能しません。
よろしくお願いいたします。