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 26th, 2008, 07:06 AM
Authorized User
 
Join Date: Jan 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Text property

Hi
i am trying to concatenate the value of variable s with the text property of the Literal control. But keep getting the error message:

ATTRIBUTE S IS NOT A VALID ATTRIBUTE OF ELEMENT LITERAL

Thanks



<table >
            <tr><%Dim s As String = "<h2>January - </h2>" & category%>
                <td><asp:Literal runat = "server" ID="IDJanuary" Text ="January" & s></asp:Literal></td></tr></table>
 
Old March 27th, 2008, 03:07 AM
Authorized User
 
Join Date: Mar 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

you cad do this at runtime Like :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim s As String = "<h2>January - </h2>"
        IDJanuary.Text = IDJanuary.Text & s

    End Sub

but you can not concate like you have given so remove s and try to do at runtime.

 
Old March 27th, 2008, 07:37 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Quote:
quote:Originally posted by imjigu2001


but you can not concate like you have given so remove s and try to do at runtime.

Yes you can. The syntax is a bit off. First I want to be up front that I agree with imjigu2001, this is something you should handle in your code behind if, for nothing else, to maintain seperation between your UI and program logic.

If you want to mix script with design however, something like this would work:

<%= "<h2>January - </h2>" & category%>

Notice the addition of the equals sign. My only other concern here is that, I assume, category is a variable that is declared in your code behind which means you have it declared (probably) as public, correct? There is nothing wrong with this but I think you would be better off using imjigu's code.

-Doug

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Text Box .text Property Displays conflicting Valus JPOhlman Visual Basic 2005 Basics 3 August 23rd, 2006 02:39 PM
text-property in a non-server control propellis .NET Web Services 0 July 4th, 2006 03:29 AM
Can't set text property of dynamic text box sreerajrs ASP.NET 1.0 and 1.1 Professional 1 May 31st, 2006 09:39 PM
User Control Name in a Text Property laslanid Pro VB.NET 2002/2003 0 February 24th, 2005 04:31 AM
TextBox.Text property returns only old value? humour General .NET 9 August 3rd, 2004 07:01 AM





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