Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing/Setting the property value of an object property of an ASP.NET User Control - Using Decalarative Syntax
    text
    copied!<p>I feel like I recall from days gone by an article explaining how to DECLARATIVELY set the value of the property of an object, exposed as the property of an ASP.NET User Control. </p> <p>My situation is that I have a user control which contains a LinkButton, amongst other things, of course. I would like the consumer of the User Control to be able to set the TEXT value of the link button in the declarative syntax used to implement the User Control. </p> <p>Here is the User Control (designer)... </p> <pre><code>&lt;div id="toolbar"&gt; &lt;ASP:LinkButton runat="server" id="btnFirst" /&gt; &lt;ASP:LinkButton runat="server" id="btnSecond" /&gt; &lt;ASP:LinkButton runat="server" id="btnThird" /&gt; &lt;ASP:LinkButton runat="server" id="btnFourth" /&gt; &lt;/div&gt; </code></pre> <p>Here is the property as defined in the code behind of the User Control ...</p> <pre><code>public partial class Lookuptoolbar: UserControl { public LinkButton FourthButton { get { return (this.btnFourth); } } } </code></pre> <p>When I include the control in a page I EXPECTED to be able to set the TEXT of my FOURTH button using the following DECLARATIVE syntax ...</p> <pre><code> &lt;UC:MyControl id="uc1" runat="server" FourthButton_Text="Click Me!"/&gt; </code></pre> <p>I had read once somewhere, a long time ago, that you could access the properties of an object (exposed as the property of a user/server control) by using the underscore syntax. This is not working for me at all. Is this no longer allowed or am I missing something? IS there ANY way of doing this?</p> <p>Thank You, Gary</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload