CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1

    Controlling ascx properties in .cs

    Hello, I am using a ascx control to style properties in a asp.net website. There are multiple aspx pages that use this ascx control. Is there a way that I can change properties of the ascx page using the current page's aspx.cs file?

    For example: (in ascx)<asp:Label Text="Hello" ID="helloText" runat="server"/>

    (in index.aspx.cs) if("some 'if' statement")
    helloText.Text="Goodbye";

    My .cs files currently do not recognize the ascx attributes. Is this even possible? Thanks

  2. #2
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: Controlling ascx properties in .cs

    You need a property in your usercontrol (.ascx) to set the value of your label.
    Then call that property from your page (.aspx) using the ID you gave the usercontrol.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured