Link to code properties on .aspx page?

On an .aspx page, what is the best way to associate a server management property with a page class property (its code)? The only way I read is to use data binding:

<asp:TextBox ID="txt" runat="server" Text='<%# Me.SomePropOfMine %>' />

and then call Me.txt.DataBind()or Me.Databind()from code. Is there a way to set this relationship only on the .aspx page or to simplify the process if you have many controls to bind (without bind the whole page)?

+3
source share
3 answers

Databind() Me ( PlaceHolder ). Databind() Child.

, DataBinding, ,

http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx

<%$ Code: Me.Property %> <%# Me.Property %>.

, , : http://www.4guysfromrolla.com/articles/022509-1.aspx

, <%= Me.Property %> - , <asp:TextBox ... ...

P.S.

Code , intellisense. , <%= Me.TestSomething %> , intellisense, <%= <%$ Code: . , DataBind(), , , . , ), .

+3

:

  • <% = <% #, .
  • Page.DataBind() .
+3

, CodeExpressionBuilder.

But the question is, why do you want to set properties in markup, not in code? If they are dynamic and connected with logic (and probably they are), then you should install them in code, even if it looks inconvenient - this will support logic in one place and markup in others.

0
source

All Articles