wrong position

Last post 10-13-2008 8:52 AM by maheshin. 5 replies.

Sort Posts:

  • wrong position

    10-13-2008, 5:32 AM
    • Member
      8 point Member
    • dr_csharp
    • Member since 12-18-2007, 3:16 PM
    • vs.net
    • Posts 101

    hello friends

    i have a content page using a master page,i put some DIV tag in content:

     

    <asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
        <div id="dailyStatement">
            daily statement
        </div>
        <div id="search">
            search engine
        </div>
        <div id="aboutCity">
            about city
        </div>
        <div id="news">
            last news
        </div>
        <div id="picGallary">
            picture gallary
        </div>
    </asp:Content>
     

    and css file is :

    #dailyStatement
    {
    	position: absolute;
    	top: 120px;
    	left: 440px;
    	width: 400px;
    	height: 50px;
    }
    
    #search
    {
    	position: absolute;
    	top: 120px;
    	left: 50px;
    	width: 390px;
    	height: 50px;
    }
    
    #aboutCity
    {
    	position: absolute;
    	top: 180px;
    	left: 440px;
    	width: 400px;
    	height: 340px;
    }
    
    #news
    {
    	position: absolute;
    	top: 180px;
    	left: 50px;
    	width: 380px;
    	height: 200px;
    }
    #picGallary
    {
    	position: absolute;
    	top: 390px;
    	left: 50px;
    	width: 380px;
    	height: 130px;
    }
    

     

    for example when i set dailyStatement to runat="server" to achieve in codebehind,the dailyStatement div position changed in my page .

    whats wrong ?

    when i open my eyes,today was past ...
  • Re: wrong position

    10-13-2008, 6:13 AM
    • Member
      198 point Member
    • techieanuj
    • Member since 05-10-2007, 11:20 AM
    • India
    • Posts 52

     Hi!

        I think when you make your Div a server-side control by putting runat="server" in the Div tag, then the CSS doesn't applies to it (usually for server-side controls, CssClass tag is used to apply CSS on them). So, make a css class for your server-side Div control and apply css on it like CssClass="class1". Hope that this helps.

     

    Anuj
     

  • Re: wrong position

    10-13-2008, 6:14 AM
    • Member
      198 point Member
    • techieanuj
    • Member since 05-10-2007, 11:20 AM
    • India
    • Posts 52

     Hi!

        I think when you make your Div a server-side control by putting runat="server" in the Div tag, then the CSS doesn't applies to it (usually for server-side controls, CssClass tag is used to apply CSS on them). So, make a css class for your server-side Div control and apply css on it like CssClass="class1". Hope that this helps.

    Anuj
     

  • Re: wrong position

    10-13-2008, 6:27 AM
    Answer

    It would appear that when you add runat="server" to an HTML tag it will only respond to its CLASS type and not its ID when referenced in a style sheet..

    just change it as class; as..

     

    .dailyStatement
    {
    position: absolute;
    top: 120px;
    left: 440px;
    width: 400px;
    height: 50px;
    }
     
    and
     <asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    <div id="dailyStatement" runat="server" class="dailyStatement">
    daily statement
    </div>
    <div id="search">
    search engine
    </div>
    <div id="aboutCity">
    about city
    </div>
    <div id="news">
    last news
    </div>
    <div id="picGallary">
    picture gallary
    </div>
    </asp:Content>
     
    hope it helps./. 
    नमस्ते,
    [KaushaL] || BloG || MS MVP

    "I would love to change the world, but they won’t give me the source code"


    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers.
  • Re: wrong position

    10-13-2008, 8:41 AM
    • Contributor
      2,579 point Contributor
    • Rinze
    • Member since 08-15-2007, 2:56 PM
    • Leiden, Netherlands
    • Posts 477

    this is because .Net likes to ensure all your server side elements have a unique ID. When using a contentplaceholder, the placeholder ID is added to the controlID. Just have a look at the div tag in your html source when you set it to runat="server".

    Using a class as described by kaushal above will solve this problem.  

    Hope this helps !
    Rinze Cats

    ---------
    please select 'mark as answer' if this post helped you!
  • Re: wrong position

    10-13-2008, 8:52 AM
    • Member
      112 point Member
    • maheshin
    • Member since 10-06-2008, 2:49 AM
    • India
    • Posts 23

    Even I had similar problem your resolution helps in resolving the problem..

    Sincerely,
    Mahesh Sundar
    Microsoft Certified Application Developer
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
    Answer” if a marked post does not actually answer your question.
Page 1 of 1 (6 items)
Microsoft Communities