Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 March 14th, 2006, 05:20 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default Losing it with Labels.. Doh!

Hi All

I am trying to pack my label's text property with both databound content and HTML but for some reason when I do this my page doesn't seem to process the databound part of it. Is there a way to combine them both as i am trying to achieve..

Code:
<asp:Label ID="Label1" runat="server" 
Text='<p><b><%# Eval("TextField1") %></b></p>'>
</asp:Label>
Many thanks

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old March 15th, 2006, 06:43 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

Oh boy I feel a little embarrased...

This works great...

<asp:Label ID="Label1" runat="server"><p><b><%# Eval("TextField1") %></b></p></asp:Label>

Basically removed the text property and positioned the content between the open and closed tags of the label.

Rit
 
Old March 15th, 2006, 06:58 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

For situations where you need to set a property like Text, you can also use this:

<asp:Label ID="Label1" runat="server"
Text='"<%# "<p><b>" + Eval("TextField1") + "</b></p>" %>'>
</asp:Label>

Basically, you need to make the fixed HTML part of the data binding expression.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 15th, 2006, 07:06 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

Excellent thanks Imar,

Looking forward to your book release shortly... ASP.NET 2.0 Instant Results...
It will prove to be very useful.

Rit
 
Old March 15th, 2006, 03:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Glad to know I am not the only one looking forward to it. I can hardly wait... ;)

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 15th, 2006, 04:40 PM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default

I'll tell you the main reason... I am no pro as yet but I have learnt so much in a short period of time and I think this is due to 2 key things:

1. Having support from Gurus like yourselves
2. Having a real life solution to develop.

By the sounds of it your book consists of both of these delights... recipe for success!

Rit





Similar Threads
Thread Thread Starter Forum Replies Last Post
Losing a session variable Abbas Classic ASP Professional 2 March 21st, 2007 04:00 PM
DAP losing connection.... kalebson Access 4 July 10th, 2006 09:05 AM
Variables losing their values jrensink78 ASP.NET 1.0 and 1.1 Basics 3 April 13th, 2006 01:09 PM
Losing variables bluemat XSLT 2 October 16th, 2004 01:59 AM





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