Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

.NET Inherited Control

  • 25-07-2011 2:06pm
    #1
    Registered Users, Registered Users 2 Posts: 527 ✭✭✭


    Hi all,

    I have created a very simple custom control:
    [assembly: System.Web.UI.TagPrefix("CustomMultiLineTextBox", "evo")]
            public class CustomMultiLineTextBox : 
                System.Web.UI.WebControls.TextBox
            {
    
                public override int Rows
                {
                    get
                    {
                        return 5;
                    }
                }
    
                public override System.Web.UI.WebControls.TextBoxMode TextMode
                {
                    get
                    {
                        return System.Web.UI.WebControls.TextBoxMode.MultiLine;
                    }
                }
        public override string CssClass
                {
                    get
                    {
                        return "textboxStyle";
                    }
                    set
                    {
    //base.CssClass = "textboxStyle";
                        base.CssClass = value;
                    }
                }
            }
            }
    

    However, when I drop this control onto my aspx page the CssClass does not seem to be applied. The TextMode and Rows property are set correctly.
    <evo:CustomMultiLineTextBox ID="txtTrainingNeeds" runat="server">
    </evo:CustomMultiLineTextBox>
    

    Only if I add CssClass="textboxStyle" to the markup will the CssClass be applied.

    Any suggestions?

    Thanks in advance


Comments

  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    What happens if you leave CssClass=""? Maybe the textbox control requires that the cssclass property isn't null?


  • Registered Users, Registered Users 2 Posts: 527 ✭✭✭Sean^DCT4


    Hi John,

    Thanks for the suggestion. I was thinking that earlier on this morning and that didn't work when I left it empty..

    Just, added this and removed the override on the CssClass and it worked:
    public CustomMultiLineTextBox()
    {
        CssClass = "textboxStyle";
    }
    


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    Sean^DCT4 wrote: »
    Hi John,

    Thanks for the suggestion. I was thinking that earlier on this morning and that didn't work when I left it empty..

    Just, added this and removed the override on the CssClass and it worked:
    public CustomMultiLineTextBox()
    {
        CssClass = "textboxStyle";
    }
    

    That's strange! Must be a IsNullOrEmpty check instead of just a null check.

    Edit: sorry, just saw the CSS at the top!


Advertisement