c# HtmlGenericControl not rendering

440 Views Asked by At

I've got a aspx page that dynamically renders social media sharing links.

The code looks something like this.

System.Web.UI.HtmlControls.HtmlGenericControl newDiv =      
    new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");

newDiv.ID = "customFB1";
newDiv.InnerHtml = "<div class='fb-share-button' data-href='http://www.website.com/folder/"+custNumber+".html' data-layout='button_count' data-mobile-iframe='true'><a class='fb-xfbml-parse-ignore' target='_blank' href='https://www.facebook.com/sharer/sharer.php?u=http://www.website.com/folder/"+custNumber+".html&amp;src=sdkpreparse'>Share</a></div>";
customFB.Controls.Add(newDiv);

Now the source works perfectly. Unfortunately 80% of the time when the page loads I have to hit F5 (hard refresh) to actually render the html. When I expect the source when its not render, its there, but won't display.

Any thoughts on how I can get the control to render without hitting F5. My customers won't know to hit F5 hah.

Thanks,

0

There are 0 best solutions below