Wrox Programmer Forums
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 12th, 2013, 01:06 AM
Registered User
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy How to concatenate strings in forms?

Hello folks,

Quick question. I am trying to concatenate a string and a database value in a form (aspx file). I know how to do this on code behind file in C++ or VB.NET, however, is not working in ASP.NET.

I have the following code of line that assigns the PictureURL database field to the ImageURL property of this image control:

<asp:Image ID="ImageUrl" runat="server" ImageUrl='<%# Eval("PictureURL") %>' />

However, the value of ImageUrl I want is a concatenation of the string "~/Pictures/" and the PictureURL database value.

I thought that the following modified line of code would work but I does not:

<asp:Image ID="ImageUrl" runat="server" ImageUrl='<%string.concat("~/Pictures/",Eval("PictureURL"))%>' />

Can you please advice me on the right way to do this?

I really appreciate your time and support on this.

Old September 12th, 2013, 04:17 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

You can use the + (& when using VB) symbol:

asp:Image ID="ImageUrl" runat="server" ImageUrl='<%# "~/Pictures/" + Eval("PictureURL") %>' />

Hope this hellps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Old September 18th, 2013, 05:25 PM
Registered User
Join Date: Jul 2013
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

That worked! Thanks a lot Imar!

Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenate help lryckman Access VBA 3 October 12th, 2009 08:52 AM
XSLT: Need to concatenate strings in loop and hold them for later use sandeepbhutani304 XSLT 3 January 9th, 2009 11:31 AM
Concatenate Rows stonesbg ASP.NET 2.0 Basics 5 February 6th, 2007 06:12 PM
concatenate with characters lily611 ADO.NET 1 July 21st, 2004 08:10 AM
Concatenate numbers fs22 Javascript 1 April 25th, 2004 06:51 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.