Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I dummied down the method to this: </p> <pre><code>@helper RenderConnectButton(System.Web.Mvc.HtmlHelper helper, ContactTwitterHandleDto contactTwitterHandle, ContactFacebookAccountDto contactFacebookAccount) { &lt;ul class="socialMedia inlineList"&gt; @if (contactTwitterHandle != null &amp;&amp; contactTwitterHandle.IsValid.HasValue &amp;&amp; contactTwitterHandle.IsValid.Value) { var tHandle = contactTwitterHandle.Handle; &lt;li class="twitter"&gt; &lt;a class="btn" href="http://twitter.com/@tHandle" target="_blank"&gt; &lt;i&gt;&lt;/i&gt; &lt;span class="label"&gt;@tHandle&lt;/span&gt; &lt;/a&gt; &lt;/li&gt; } &lt;/ul&gt; } </code></pre> <p>If I remove @tHandle from the line: </p> <pre><code> &lt;a class="btn" href="http://twitter.com/@tHandle" target="_blank"&gt; </code></pre> <p>It will parse fine. If I put the Url above in a variable, then I get the error.</p> <p><strong>It's failing when trying to parse a string that is a Url.</strong></p> <p>Stack trace:</p> <pre><code> at System.Web.WebPages.HelperPage.WriteAttributeTo(TextWriter writer, String name, PositionTagged`1 prefix, PositionTagged`1 suffix, AttributeValue[] values) at ASP.MvcSocialMediaHelpers.&lt;&gt;c__DisplayClass1.&lt;RenderConnectButton&gt;b__0(TextWriter __razor_helper_writer) in c:\OberonScrum\Branches\RazorUpgrade\Source\Web\App_Code\MvcSocialMediaHelpers.cshtml:line 83 at System.Web.WebPages.HelperResult.ToString() at System.String.Concat(Object arg0, Object arg1) at ASP.views_contact_detail_aspx.__RenderMainContent(HtmlTextWriter __w, Control parameterContainer) in c:\OberonScrum\Branches\RazorUpgrade\Source\Web\Views\Contact\Detail.aspx:line 13 at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at ASP.views_shared_twocolumnleftmain_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\OberonScrum\Branches\RazorUpgrade\Source\Web\Views\Shared\TwoColumnLeftMain.Master:line 109 at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) </code></pre> <p>[UPDATE] Tried working around the issue using TagBuilder and rendering with Html.Raw(); got the same result.</p> <pre><code>@helper RenderConnectButton(System.Web.Mvc.HtmlHelper helper, ContactTwitterHandleDto contactTwitterHandle, ContactFacebookAccountDto contactFacebookAccount) { &lt;ul class="socialMedia inlineList"&gt; @if (contactTwitterHandle != null &amp;&amp; contactTwitterHandle.IsValid.HasValue &amp;&amp; contactTwitterHandle.IsValid.Value) { var tHandle = contactTwitterHandle.Handle; var a = new TagBuilder("a"); a.Attributes.Add("href", "http://twitter.com/" + @tHandle); a.Attributes.Add("target", "_blank"); a.Attributes.Add("class", "btn"); a.InnerHtml = string.Format("&lt;i&gt;&lt;/i&gt;&lt;span class=\"label\"&gt;{0}&lt;/span&gt;", @tHandle); &lt;li class="twitter"&gt; @Html.Raw(a.ToString()) &lt;/li&gt; } &lt;/ul&gt; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload