locked
Usercontrol and stylesheet RRS feed

  • Question

  • User-2139489267 posted

    Hello everyone,

    I am using portal starter kit 1.1. I've developed forums.ascx user control and applied some styles to it and embedded it in  forums.aspx page. Now what happens when user open this .aspx page by clicking tab, it's ok. now i've another page. when user will be redirected from that page to forums.aspx (same user control page) everything changes. styles, width, height, alignment and also it's not able to find some images which are displayed when the page loads first time.


    when first time load: 


     

    when Second time load:

    and help will be appreciated..

    Regards,

    Nil 

     

     

    Thursday, June 19, 2008 9:59 AM

Answers

  • User-16411453 posted

    css sheets have to be loaded inside the head tags.  I can't see how the below will work, esspecially if the control resides different folder levels.  Others should be able to help on this one.

    ../ASPNETPortal.css

    /ASPNETPortal.css

    ~/ASPNETPortal.css

     

    <%@ Control AutoEventWireup="true" CodeFile="Forums.ascx.cs" Inherits="ASPNET.StarterKit.Portal.Forums"
        Language="C#" %>
    <%@ Import Namespace="ASPNET.StarterKit.Portal" %>
    
    <link rel="Stylesheet" type="Text/css" href="../ASPNETPortal.css" />
    
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 20, 2008 2:07 PM

All replies

  • User478821305 posted

    You can dynamically inject your .css include by sticking something like this in the Page_Load for your .ascx. That way it will include the automatically on any page with the user control

    Page.ClientScript.RegisterClientScriptBlock(GetType(), "name of block", "&lt;link rel='StyleSheet' type='text/css' href='url to .css' />");
    
      
    Thursday, June 19, 2008 12:40 PM
  • User-16411453 posted

    Why not just look at the web page source, and compare the two; to what has changed, instead of posting something we can't see or visualize. 

    Thursday, June 19, 2008 6:39 PM
  • User-2139489267 posted

     Sorry friends images i attached are not visible..so here i am posting source code of my user control and web page in which it is embedded.

    Forums.ascx (User Control)

     

    <%@ Control AutoEventWireup="true" CodeFile="Forums.ascx.cs" Inherits="ASPNET.StarterKit.Portal.Forums"
        Language="C#" %>
    <%@ Import Namespace="ASPNET.StarterKit.Portal" %>
    <link rel="Stylesheet" type="Text/css" href="../ASPNETPortal.css" />
        
    <div class="forumcontent">
        <asp:Repeater ID="ForumRepeater" runat="server" OnItemDataBound="ForumRepeater_ItemDataBound"
            EnableTheming="true">
            <HeaderTemplate>
                <table width="100%" cellspacing="0">
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <td colspan="4" style="background-color: #ccdcee; border: 1px solid #606D85;">
                        <asp:Label ID="lblname" runat="server" Font-Size="Medium" ForeColor="black" Text='<% #Eval("ForumName") %>'>
                        </asp:Label><br />
                        <asp:Label ID="lbldescription" runat="server" Font-Size="X-Small" ForeColor="Black"
                            Text='<% #Eval("ForumDescription") %>'></asp:Label>
                    </td>
                </tr>
                <tr>
                    <th>
                    </th>
                    <th style="width: 50%;">
                        <asp:Label ID="Label1" runat="server" Text="Topics">
                        </asp:Label>
                    </th>
                    <th>
                        <asp:Label ID="Label2" runat="server" Text="Last Post">
                        </asp:Label>
                    </th>
                    <th>
                        <asp:Label ID="Label3" runat="server" Text="Threads"/>
                    </th>
                </tr>
                <asp:Repeater ID="topicpart" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td align="center">
                                <asp:Image ID="Image1" runat="server" ImageUrl="~/images/forum.gif" />  </td>
                            <td>
                               <h2><asp:LinkButton ID="lnkname" runat="server" PostBackUrl='<% #Eval("TopicID","Threads.aspx?Topic={0}") %>'
                                Text='<% #Eval("TopicName") %>' ForeColor="Blue" /></h2>
                             
                                <%# Eval("TopicDescription") %>
                            </td>
                            <td>
                           <%# Eval("LastPostDate") %><br />
                            <%# Eval("UserName") %>
                            </td>
                            <td align="Center" style="font-weight:bold;">
                          <%# Eval("Threads") %>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </ItemTemplate>
            <FooterTemplate>
                </table></FooterTemplate>
        </asp:Repeater>
    </div>

      Here's my Forums.aspx page code in which user control is embedded..

      

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Forums.aspx.cs" Inherits="Forums" %>
    <%@ Register src="Forums.ascx" TagName="Forums" TagPrefix="ASPNETPortal" %>
    <%@ Register src="~/DesktopPortalBanner.ascx" TagName="Banner" TagPrefix="portal" %>
    <%@ Import Namespace="ASPNET.StarterKit.Portal" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <link href="../ASPNETPortal.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form runat="server">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr valign="top">
                    <td>
                        <portal:Banner ID="Banner1" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="forumcontent">
                            <ASPNETPortal:Forums ID="forum1" runat="server" EnableTheming="true" />
                        </div>
                    </td>
                </tr>
            </table>
        </form>
    </body>
    </html>
      Css Styles that i applied to this user control:
     .titlehead th 
     {
    	color:Black;
    	font-weight: bold;
    	font-size: 9pt;
    	text-align: left;
    	padding: 5px 5px 5px 5px;
    	border:1px solid #606D85;
    	background-color:#dce4f9;
    	
    	 }
    .forumcontent table {font-size: 8pt;border-collapse:collapse;background-color:#FFFFFF;}
    .forumcontent h1 {font-weight: normal;font-size: 18pt;margin-bottom: 0px;font-family: 'Arial Narrow';}
    .forumcontent h2 {margin-bottom: 0px;font-size: 10pt;}
    .forumcontent h3 {font-weight: bold;font-size: 8pt;margin-bottom: 0px;}
    .forumcontent a {color: #333399;text-decoration: underline;}
    .forumcontent a:hover{text-decoration: none;}
    .forumcontent th {color:Black;font-weight: bold;font-size: 9pt;text-align: center;padding: 5px 5px 5px 5px;border:1px solid #606D85;}
    .forumcontent th a {color: White;font-size: 8pt;font-weight: normal;text-decoration: none;}
    .forumcontent th a:hover{text-decoration:underline;}
    .forumcontent td {border:1px solid silver;}
    .forumcontent button{font-family: Verdana;font-size: 8pt;border: slategray 1px solid;}
    .forumcontent textarea{font-family: Verdana;font-size: 8pt;border-left: slategray 1px solid;border-right: slategray 1px solid;border-bottom: slategray 1px solid;border-top: none;}
    .forumcontent select{font-family: Verdana;font-size: 8pt;border: slategray 1px solid;}
    .forumcontent img{vertical-align:middle;border:none;}
    .forumcontent hr{height:1px;border:none;color:silver;background:silver;}
    .forumcontent div.location{margin-top:17px;margin-bottom:17px;}

     I think now there won't be any problem to understand everything..any help will be appriciated..Thanks..

    Regards,

    Nil 

    Friday, June 20, 2008 1:07 AM
  • User-16411453 posted

    css sheets have to be loaded inside the head tags.  I can't see how the below will work, esspecially if the control resides different folder levels.  Others should be able to help on this one.

    ../ASPNETPortal.css

    /ASPNETPortal.css

    ~/ASPNETPortal.css

     

    <%@ Control AutoEventWireup="true" CodeFile="Forums.ascx.cs" Inherits="ASPNET.StarterKit.Portal.Forums"
        Language="C#" %>
    <%@ Import Namespace="ASPNET.StarterKit.Portal" %>
    
    <link rel="Stylesheet" type="Text/css" href="../ASPNETPortal.css" />
    
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 20, 2008 2:07 PM