Reputation: 7674
Is there a way pass values from other controls (e.g. "selected value of dropdownlist", "value from query string") to a User Control using a property within the tag itself and NOT from the code behind?
Upvotes: 1
Views: 1464
Reputation: 43815
Yes you can, you just need to use the <% %>
in the presentation code. Your code would look something like this:
<asp:DropDownList id="ddlFoo" runat="server">
...
</asp:DropDownList>
<asp:TextBox id="txtBar" runat="server" Text='<%# ddlFoo.SelectedValue %>' />
<%-- For query string --%>
<asp:TextBox id="txtBar" runat="server"
Text='<%# Request.QueryString["Key_Value"] %>' />
The SO post In ASP.Net, what is the difference between <%= and <%# gives a good listing of the different binding mechanisms you can use.
Upvotes: 1
Reputation: 7356
Yes it is. For example
<uc1:CompetitionClassification ID="CompetitionClassification" runat="server" OnlyTopFive="True" />
in this case, the parameter OnylTopFive is passed within tag of my custom control.
then in server side of my control, i have :
private bool onlyTopFive;
public bool OnlyTopFive
{
get
{
return this.onlyTopFive;
}
set
{
this.onlyTopFive = value;
}
}
Upvotes: 0