Reputation: 671
I have seen it done before but i cannot remember where (vs2012 even):
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
Some tag I can add to the label (or textbox?)
So that when I bind "Hello World!" to the label, I can have the label output: "Welcome, Hello World!"
My label would look like:
<asp:Label ID="lblMessage" runat="server" Text="" PrependedText="Welcome, "></asp:Label>
Upvotes: 0
Views: 960
Reputation: 32694
Several ways to go about this...
Welcome, <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
or
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
lblMessage.Text="Welcome, Hello World!";
or
public class MySpecialLabel: Label
{
public string PrependedText {get;set;}
//logic here to handle combining the strings when Text is set.
}
or
<div class="WelcomeSection">
Welcome, <asp:Label runat="server" id="lblMessage">
</div>
Upvotes: 1
Reputation: 942
You can write your own control derived from Label or just put another before with text from resources or hardcoded:
<asp:Label ID="lblPrepend" runat="server" Text="Welcome, " />
<asp:Label ID="lblMessage" runat="server" Text="" />
Upvotes: 1