+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Widget added inside span

Widget added inside span

3 posts, 1 answered
  1. Liviu
    Liviu avatar
    13 posts
    Registered:
    15 Feb 2012
    07 Nov 2013
    Link to this post
    Hello, 
    I have a widget like this:

    <%@ Control Language="C#" %>
    <asp:HyperLink runat="server" ID="lnk" class="box">
        <asp:Image ID="img" runat="server"></asp:Image>
        <asp:Literal ID="lt" runat="server" />
    </asp:HyperLink>

    But when the widget is dropped on page, SPAN tag appear and change all my CSS.

    <div class="news_archive">
    <span>
           <a class="box" id="ContentPlaceHolder1_v1TopHolder_ctl00_ctl00_ctl00_lnkCallout">
                 <img src="" id="ContentPlaceHolder1_v1TopHolder_ctl00_ctl00_ctl00_imgCallout"></a>
                //start literal
                <h3>
                             <a href="http://news_archive.html#">News Archives</a>
               </h3>
              //endliteral
    </span>
    </div>

    And this widget is dropped in 

    <div class="news_archive">
                    <asp:ContentPlaceHolder ID="v1TopHolder" runat="server">
    //here
                    </asp:ContentPlaceHolder>
    </div>

    Somebody may know why is that SPAN added and how can i remove it?

    Thanks!
  2. Liviu
    Liviu avatar
    13 posts
    Registered:
    15 Feb 2012
    07 Nov 2013
    Link to this post
    I found the solution and i will post here, maybe somebody else will need.
    The key is to averride a function inside widget .cs file, be carefull, not in designer.
     protected override void Render(HtmlTextWriter writer)        {            RenderContents(writer);        }

    Good luck!
    Answered
  3. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
    07 Nov 2013 in reply to Liviu
    Link to this post
    I think that's actually an ASP.NET issue, rather than a Sitefinity issue, and that 'fix' is typical for ASP.NET controls.

    Personally, I avoid using the simple ASP.NET controls where ever possible, and just add runat="server" and clientmode="predictable" to standard html elements, when I need code-behind access.

    Of course, there are still times when you need those simple ASP.NET controls, but most times you don't.
3 posts, 1 answered