5. Control tree

ID Attributes: id & sid When any xml element has one of the two id attributes, it will become available as a server side control. There is a difference in using both id attributes:

- sid Is the server-side id, is guaranteed to be unique inside the page. The sid provided by the user can be only one element, for example ‘myControl’, but in code the framework might expand this to ‘myContainer.myControl’, to assure the uniqueness of the sid.

The user provided sid is available in the SasControl?.Id property, the unique generated id is available in the SasControl?.UniqueId? property.

The attribute sid is never rendered client-side. If you wish to have an element available server-side, but not let it have an id attribute client-side, only provide a ‘sid’ attribute. - id Represents the client-side id, not always guaranteed to be unique. There are two distinct cases in using the id attribute:

id without sid attribute The id attribute will take the role of the sid attribute and will generate the unique server-side id. The only difference is that the server-side id will also be rendered client-side as an id attribute.

id in combination with sid The id attribute is the client-side id only. This is the id that will be rendered in the final output, the sid will be used for all server-side actions.

The client-side id is available in the SasControl?.ClientId? property.

If you wish to develop controls that are reusable in other applications, avoid using id in combination with sid, because then you have to make sure you create your own unique client-side ids.

SasControl?.Id property The scope of uniqueness of the SasControl?.Id property, is the parent control. In the parent control, no two controls can have the same Id value.

Like in normal ASP.NET, the SasControl?.Id property will be used to automatically link controls to fields (not properties!) of the parent control.

Example of control tree:

HTML

<ns:MyControl sid=”myCtl” someAttribute=”someValue”>

<p>paragraph, no id so no control</p> <p id=”myPara”>paragraph id so control</p>

</ns:MyControl>

Control tree

+ MyControl? [UniqueId?=myCtl,Id=myCtl,ClientId?=] - Literal [UniqueId?=,Id=,ClientId?=] + GenericControl? [UniqueId?=myCtl.myPara,Id=myPara,ClientId?=myCtl.myPara] - Literal [UniqueId?=,Id=,ClientId?=]

Controls can have hidden attributes: attributes available server-side, but not rendered to the client output. To specify a hidden attribute in a view file, start the attribute name with an underscore. In code behind you can use the Hide(), Show() and IsHidden?() methods of the Attributes property (type AttributeMap?) to manage hidden attributes.

By id Find By attribute Select SasControlSet? ds

4. Control lifecycle | 6. View variables & using the Bag