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

Forums / Bugs & Issues / User control content positions not retained on insertion into page

User control content positions not retained on insertion into page

6 posts, 1 answered
  1. CDM
    CDM avatar
    4 posts
    Registered:
    23 Jan 2010
    02 Feb 2010
    Link to this post
    Support,

    I have created a very simple user control that basically positions two labels.   When inserting into a page content area (the default master page of a site created using the Create new project admin tool) - the position of the label controls is not retained.  The controls were added through the page editor and I checked that the web.config entries were as described in the manual.

    Notice that the positions of the labels are offset - when added to the page this was ignored.  This is a great simplification of a much more complex control - hopefully it will give you enough to go on.  Please let me know if there is something that I am not understanding here.  Many thanks in advance; -- CDM.

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="PFSWUC02.ascx.cs" Inherits="UserControls_PFSWUC02" %>
    <
    br><asp:Label ID="Label1" runat="server" Text="Very simple User Control"></asp:Label><br><asp:Label ID="Label2" runat="server" Style="top: 22px; left: 191px; position: absolute;<br>    height: 19px; width: 124px" Text="Second piece of text"></asp:Label>
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    02 Feb 2010
    Link to this post
    Hello CDM,

    Perhaps there is an styling error in one of the labels, that you might want to check -

    <asp:Label ID="Label2" runat="server" Style="top: 22px; left: 191px; position: absolute;<br>    height: 19px; width: 124px" Text="Second piece of text"></asp:Label>

    Can you please check if this is causing the problem?

    All the best,
    Georgi
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. CDM
    CDM avatar
    4 posts
    Registered:
    23 Jan 2010
    02 Feb 2010
    Link to this post
    Georgi,

    The extra break seems to have been inserted when I copied the code into the forum text box.  Here is the original

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="PFSWUC02.ascx.cs" Inherits="UserControls_PFSWUC02" %>
    <asp:Label ID="Label1" runat="server" Text="Very simple User Control"></asp:Label>
    <asp:Label ID="Label2" runat="server" Style="top: 22px; left: 191px; position: absolute;
        height: 19px; width: 124px" Text="Second piece of text"></asp:Label>

     -- CDM
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    02 Feb 2010
    Link to this post
    Hi CDM,

    Alright, I have tried your control, and here is the explanation of what happens - In Page Edit mode, every control runs in its own context. This is needed so we can handle the errors and still have the editor opened. This means that the following style:

    top: 22px; left: 191px; position: absolute; height: 19px; width: 124px;
    will be position the element in absolute position on the page (but in page edit mode - in the context). 

    If we want to have the styling positioned according to masterpage's settings, you should change the style to position: relative. In this case, in both cases (page edit or not) the element will be positioned relative to it's parent, rather to the whole page. The correct style should be:

    top: 22px; left: 191px; position: relative; height: 19px; width: 124px;

    I hope this helps. 

    Greetings,
    Georgi
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
    Answered
  5. CDM
    CDM avatar
    4 posts
    Registered:
    23 Jan 2010
    02 Feb 2010
    Link to this post
    Georgi,

    You have the answer.  I will have to think more deeply about this issue and apologize for not being able to figure this out before requesting help.

     --- CDM
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    02 Feb 2010
    Link to this post
    Hi CDM,

    No worries. Let me know if you need any further assistance or doubts about this - we will be glad to help. 

    Best wishes,
    Georgi
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Register for webinar
6 posts, 1 answered