Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I concatenate 2 resource strings together in an aspx page

I have a localised ASP.net application (.net 2.0). I wish to concatenate 2 strings retrieved from the resource file together into one element, something like this.

Text="<%$ Resources:Resource, lw_name %>" + <%$ Resources:Resource, lw_required %>"

I have tried using Eval without success. Is what I am trying to do the "correct" approach or can I store strings with placeholders in the resource file and interpolate them "on the fly".

I am trying to do this in the aspx file rather than in code-behind.

like image 220
Steve Weet Avatar asked Nov 19 '09 12:11

Steve Weet


People also ask

How do I combine multiple strings into one?

Concatenation is the process of appending one string to the end of another string. You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.

How do I combine double strings?

The “+” operator with a String acts as a concatenation operator. Whenever you add a String value to a double using the “+” operator, both values are concatenated resulting a String object. In-fact adding a double value to String is the easiest way to convert a double value to Strings.

What is the most efficient way to concatenate many strings together?

Concatenate Many Strings using the Join As shown above, using the join() method is more efficient when there are many strings. It takes less time for execution.

Which function is used to combine the two strings?

Use CONCATENATE, one of the text functions, to join two or more text strings into one string.


1 Answers

ASP.NET tag attribute values that use <%$ Something: Something Else %> are of a special syntax called ASP.NET Expressions. Using them as attribute values are pretty much all-or-nothing; there's no way to add any code into the ASPX file to manipulate what those expressions evaluate to. You'll have to do this in the code-behind.

like image 156
Adam Maras Avatar answered Oct 11 '22 18:10

Adam Maras