Referencing User Control Attributes in Page Code Behind

.net , user control , code behind United States
  • 6 years ago

    I'm trying to reference the attributes of a panel in a User Control in the code behind of a web page. I've tried about a dozen variations. Can't be this hard. Anybody got the correct syntax? Thanks!

    <%@ Register Src="~/inc/ceSteps.ascx" TagName="ceSteps" TagPrefix="uc1" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <uc1:ceSteps ID="ceSteps" runat="server" />
    Then on the code behind for my page:
    Dim myCtrl As UserControl = CType(FindControl("uc1"), UserControl)
    myCtrl.pnlStage1.BackColor = System.Drawing.ColorTranslator.FromHtml("#dfdfdf")
    yahda, yahda, yahda....

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou