Concatenate strings in .aspx page

| November 5, 2011 | 0 Comments

Problem

I am trying to set label value dynamically in .aspx page. Additionally I need to concatenate strings in the .aspx page.

Solution

We would need to use string.Concat() function for same. Here is solution for concatenating string values in .aspx page:

Code Snippet for .aspx:

<asp:Label ID="lblUrl" runat="server"><%= string.Concat("http://",Request.Url.Port.ToString() ,"Hello")%></asp:Label>

Above code results in string as http://80Hello.

Category: Asp.Net, C#, Error and Solution

Leave a Reply

%d bloggers like this: