Reputation: 8599
Is here any way of binding <%# Page.ClientID %>
without binding Page child controls?
For example:
<%# SomePageProprtyThatReturnsString %>
<someTag:SomeControl ID="SomeControlID" runat="server" OnDataBinding="SomeControlID_DataBinding"></someTag:SomeControl>
If I have following than SomeControlID will be bound on each unwanted post-back
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
DataBind();
}
If I will not bind page on each post back then SomePageProprtyThatReturnsString will not be visible on post-backs
Upvotes: 0
Views: 3200
Reputation: 7591
You can choose which controls you want to bind. So, if you have something like this:
<asp:Label runat="server" ID="lblSomething" Text='<%# SomePageProprtyThatReturnsString %>' />
<someTag:SomeControl ID="SomeControlID" runat="server" OnDataBinding="SomeControlID_DataBinding"></someTag:SomeControl>
You can call Databind
only on the Label
:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
lblSomething.DataBind();
}
Upvotes: 3
Reputation: 954
<%# SomePagePropertyThatReturnsString %>
Looks like it might be some public property you've created on the Page
itself? If that is the case you can output that property directly without the need for databinding by changing your code:
<%= this.Page.SomePropertyThatReturnsString %>
Upvotes: 1