Accessing custom control properties

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Accessing custom control properties

    Hello, I've created a custom control and want to set
    properties in the aspx page.

    <%@ Page language="c#" Codebehind="test_control2.aspx.cs"
    AutoEventWireup="false"
    Inherits="oldtownclovis_dotnet.test_control2" %>
    <%@ Register TagPrefix="aspCustomerGrid"
    TagName="CustomerGrid" Src="test_user_control.ascx"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN" >

    <html>
    <head>
    <title>test_control2</title>
    <LINK rel="stylesheet" type="text/css"
    href="http://localhost/oldtownclovis_dotnet/include/otc_nor
    mal.css">
    </head>
    <body MS_POSITIONING="GridLayout">

    <form id="Form1" method="post" runat="server">
    <aspCustomerGrid:CustomerGrid
    id="CustomerGrid" runat="server">
    <!-- can i set the properties
    here? -->
    </aspCustomerGrid:CustomerGrid>
    </form>

    </body>
    </html>


    How do I set the public properties of the control from
    within the customer control's tag?

    Thanks,

    Eric
    Eric Guest

  2. Similar Questions and Discussions

    1. Making Custom Control Properties Visible in Visual Studio's Properties Palette
      I am learning how to use the System.ComponentModel class in VB.NET so that I can add my ASP.NET controls to Visual Studio .NET 2003. I have managed...
    2. Building a non-databound custom template and accessing it's properties
      Hello, I've built a custom control (inherits from WebControls.Repeater) with a custom template. The intention is to make a custom paging...
    3. Accessing properties in custom control
      Hi all, This is probably a newbie question, but... I have a custom control inherited from System.Web.UI.WebControls.Table. Here is the code: ...
    4. User Control - Accessing Properties from the Container Page
      Dear all, Please check my problem - Problem: I have created a User Control(UC1) for navigating between pages. There are 4 buttons on the user...
    5. Accessing TreeView Control properties on the client side
      Hi , I want to disable (AutoPostBack) for the tree . So on the click event I am able to retrieve the index of the node clicked on the client...
  3. #2

    Default Re: Accessing custom control properties

    Hi Eric,

    Define a public property in your user control class and then add an
    attribute to the usercontrol tag named after your property, ie:
    [C#]
    public String YourProperty {
    get{ ... }
    set{ ... }
    }
    ..ASPX
    <prefix:YourUSerControlType runat="server" YourProperty="blah" />

    You won't be able to set this property using the Properties window at
    design-time, you will need to directly edit the markup, thats a limitation
    in the current bits.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    [url]http://obies.com/vga/blog.aspx[/url]
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.

    "Eric" <benzrider2000@yahoo.com> wrote in message
    news:041e01c398e9$77b81320$a401280a@phx.gbl...
    > Hello, I've created a custom control and want to set
    > properties in the aspx page.
    >
    > <%@ Page language="c#" Codebehind="test_control2.aspx.cs"
    > AutoEventWireup="false"
    > Inherits="oldtownclovis_dotnet.test_control2" %>
    > <%@ Register TagPrefix="aspCustomerGrid"
    > TagName="CustomerGrid" Src="test_user_control.ascx"%>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    > Transitional//EN" >
    >
    > <html>
    > <head>
    > <title>test_control2</title>
    > <LINK rel="stylesheet" type="text/css"
    > href="http://localhost/oldtownclovis_dotnet/include/otc_nor
    > mal.css">
    > </head>
    > <body MS_POSITIONING="GridLayout">
    >
    > <form id="Form1" method="post" runat="server">
    > <aspCustomerGrid:CustomerGrid
    > id="CustomerGrid" runat="server">
    > <!-- can i set the properties
    > here? -->
    > </aspCustomerGrid:CustomerGrid>
    > </form>
    >
    > </body>
    > </html>
    >
    >
    > How do I set the public properties of the control from
    > within the customer control's tag?
    >
    > Thanks,
    >
    > Eric

    Victor Garcia Aprea [MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139