Reputation: 4848
Here is my code:
<a href="<%= this.ResolveUrl("Search.aspx?id=" + lblGraphicNameValue.Text) %>" target="_blank">Search Related</a>
I want to take the text value of lblGraphicNameValue and remove the last four characters. Can I do this, and keep it inline? Or is this something I should do in the code behind?
Thanks!
Upvotes: 0
Views: 378
Reputation: 149050
You can also use the Remove
method:
lblGraphicNameValue.Text.Remove(lblGraphicNameValue.Text.Length - 4)
Upvotes: 2
Reputation: 22814
I think this would work:
<a href="<%= this.ResolveUrl("Search.aspx?id=" + lblGraphicNameValue.Text.Substring(0, lblGraphicNameValue.Text.Length - 4) %>" target="_blank">Search Related</a>
or also this:
<a href="<%= this.ResolveUrl("Search.aspx?id=" + lblGraphicNameValue.Text.Remove(lblGraphicNameValue.Text.Length - 4) %>" target="_blank">Search Related</a>
I'm not sure, I have no experience with ASP.NET though so I don't know if it allows arbitrary code.
Upvotes: 4