Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:00:37+00:00 2026-05-27T04:00:37+00:00

Ok I created simple user control that look like this <%@ Control Language=C# AutoEventWireup=true

  • 0

Ok I created simple user control that look like this

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PlaceHolderCMS.ascx.cs" Inherits="Controls_PlaceHolderCMS" %>

<div id="contentPlaceholder" runat="server" class="contentPlaceholderStyle">
</div>

I am using it like this

<div class="mainField" runat="server">             
  <cms:PlaceHolder ID="PlaceHolderCMS1" runat="server" class="PH1" />
  <cms:PlaceHolder ID="PlaceHolderCMS2" runat="server" />
</div>

But my problem is CSS, I can edit styles that is asociated with entire control, like this

.contentPlaceholderStyle
{
    border-style :dashed;
    background-color:transparent;
    border-width:1px; 
    padding: 10px, 10px, 0px, 0px;  
    margin:15px;
    height:100px;
}

But when i try to style single instance of user control nothing happens. I tried this from stylesheet, like this

.PH1
{    
    height:100px;
}

and from C#, like this
protected void Page_Load(object sender, EventArgs e)

{

PlaceHolderCMS1.Attributes["style"] = "width=" + width + "%; height:" + height + "px;" ;

}

So my question is how can I put style attributes for instances of my Custom Control? I want to have general styles for entire control, and override them for particular instances if needed.

Thank you in advance….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:00:38+00:00Added an answer on May 27, 2026 at 4:00 am

    Your problem is that UserControl doesn’t render any tag for himself. Since that it’s nothing to apply your class on. So it’s abolutely on you to provide some custom CssClass property for your control and assign this to some container that holds all your control children.

    Control’s markup:

    <div class='<%= CssClass %>' >
        <div id="contentPlaceholder" runat="server" class="contentPlaceholderStyle">
        </div>
    </div>
    

    Control’s code-behind:

    [CssClassProperty]
    public string CssClass
    {
        get { return (string)(ViewState["CssClass"] ?? ""); }
        set { ViewState["CssClass"] = value; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a simple user control which is manually created with something like MyUserControl
Here's the setup: I've created a user control MyUserControl. On this control is a
I created a simple user control using the AJAX Control Toolkit Accordion, LinkButton, and
I am looking to create a user/server control that will be created with something
I am using MVVM Light. I have created a window that looks like this:
I created a simple User Settings Dialog by binding the Property.Settings to a PropertyGrid
I am trying to create this simple application in c#: when the user double
How can I create board for simple game, looks like for chess,but user could
Could someone help me on this, I have created simple web services using axis2
I have a custom control Workspace that inherits from Control and within it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.