I prefer data-bound tags in the markup file document.getElementById ('<% # TextBox1.ClientID%>'). when using the server-side tag implementation <% = TextBox1.ClientID%>.
Server-side tags prevent you from adding controls to the dom in the code behind. This need usually arises when you create an application, and a database-bound approach can save you from basic overwrites.
When using tags on the server side are also known as โcode blocksโ performing this general operation
this.Form.Controls.Add (myContorl);
generates this error at runtime:
The collection of controls cannot be modified because the control contains blocks of code (i.e. <% ...%>).
Unfortunately, this often becomes apparent only after you have created your website.
When using data binding control, '<% # TextBox1.ClientID%>' resolves the value of the control properties specified in the markup to an appropriate place, such as the end of the Page_Load data, as follows:
Page.DataBind ()
Remember that Page.DataBind () calls the child controls on the page as well as a DataBind, which can be an undesirable side effect if the page handles the data binding of certain child controls separately. If so, data binding can be performed on a separate control as follows:
TextBox1.DataBind ()
As a result, the evolution of applications ultimately leads to some functionality based on the base site, where you may want to add basic controls as soon as you put the application with tags on the server side onto the site, replacing them with data links, it becomes problematic, especially when pages were encoded to handle data binding on their own.
David Sopko Jun 17 '13 at 20:55 on 2013-06-17 20:55
source share