How2 Use Expression Syntax in HTML

Discussion in 'ASP .Net' started by clintonG, Aug 25, 2005.

  1. clintonG

    clintonG Guest

    I'm not getting the hang of what I thought I already understood. Maybe
    burnout?
    I want to build a string in code and write it into the HTML for display...

    // initiliazed in code
    string someText = "someText";

    // does not exist in the current context
    <%= someText %>

    // ; expected
    <% someText %>

    // does not exist in the current context
    <% someText.ToString( ); %>

    What am I doing incorrectly this time ;-)

    <%= Clinton Gallagher
     
    clintonG, Aug 25, 2005
    #1
    1. Advertising

  2. clintonG

    darrel Guest

    > I want to build a string in code and write it into the HTML for display...

    You can add a item to your ASPX page (label/literal/etc.) and then set the
    text of that item via your codebehind page:

    yourLabel.text = someText

    Otherwise, if you want to do what you were doing, you need to dim the string
    as public:

    Public Shared someText = "someText" in your codebehind.

    -Darrel
     
    darrel, Aug 25, 2005
    #2
    1. Advertising

  3. clintonG

    clintonG Guest

    Thanks Darrel. I would be using controls but I'm actually trying to
    determine if I can use expression syntax write out the complete HTML
    declaration for an image control.

    <%= Clinton Gallagher



    "darrel" <> wrote in message
    news:%...
    >> I want to build a string in code and write it into the HTML for
    >> display...

    >
    > You can add a item to your ASPX page (label/literal/etc.) and then set the
    > text of that item via your codebehind page:
    >
    > yourLabel.text = someText
    >
    > Otherwise, if you want to do what you were doing, you need to dim the
    > string
    > as public:
    >
    > Public Shared someText = "someText" in your codebehind.
    >
    > -Darrel
    >
    >
    >
     
    clintonG, Aug 25, 2005
    #3
  4. clintonG

    Bruce Barker Guest

    the aspx page inherits from the codebehind, so you must make the string
    protected or public.

    protected string sometext = "hello";

    -- bruce (sqlwork.com)




    "clintonG" <> wrote in message
    news:...
    > I'm not getting the hang of what I thought I already understood. Maybe
    > burnout?
    > I want to build a string in code and write it into the HTML for display...
    >
    > // initiliazed in code
    > string someText = "someText";
    >
    > // does not exist in the current context
    > <%= someText %>
    >
    > // ; expected
    > <% someText %>
    >
    > // does not exist in the current context
    > <% someText.ToString( ); %>
    >
    > What am I doing incorrectly this time ;-)
    >
    > <%= Clinton Gallagher
    >
    >
    >
     
    Bruce Barker, Aug 26, 2005
    #4
  5. clintonG

    clintonG Guest

    I had problems doing so within the Page_Load event but none when
    initializing within the partial class itself.
    I have little experience using code block expressions with the DNF so you
    might find it interesting to discuss what I am trying to learn to do.

    I've been using Page_PreInit to get the value of a cookie that contains the
    name of the Theme selected from a DropDownList. I need to use that value
    from the cookie to dynamically build the entire declaration for an Image
    control before the Page class is compiled. I document the whole nine yards
    at the beta forums [1] and welcome all comments.

    <%= Clinton Gallagher
    METROmilwaukee (sm) "A Regional Information Service"
    NET csgallagher AT metromilwaukee.com
    URL http://metromilwaukee.com/
    URL http://clintongallagher.metromilwaukee.com/

    []1 http://forums.asp.net/1032623/ShowPost.aspx







    "Bruce Barker" <> wrote in message
    news:...
    > the aspx page inherits from the codebehind, so you must make the string
    > protected or public.
    >
    > protected string sometext = "hello";
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    >
    > "clintonG" <> wrote in message
    > news:...
    >> I'm not getting the hang of what I thought I already understood. Maybe
    >> burnout?
    >> I want to build a string in code and write it into the HTML for
    >> display...
    >>
    >> // initiliazed in code
    >> string someText = "someText";
    >>
    >> // does not exist in the current context
    >> <%= someText %>
    >>
    >> // ; expected
    >> <% someText %>
    >>
    >> // does not exist in the current context
    >> <% someText.ToString( ); %>
    >>
    >> What am I doing incorrectly this time ;-)
    >>
    >> <%= Clinton Gallagher
    >>
    >>
    >>

    >
    >
     
    clintonG, Aug 26, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. clintonG
    Replies:
    1
    Views:
    320
    Karl Seguin
    Oct 26, 2004
  2. John McGaw
    Replies:
    31
    Views:
    1,004
    Toby A Inkster
    Jan 12, 2004
  3. Robert Kattke
    Replies:
    0
    Views:
    443
    Robert Kattke
    Dec 31, 2003
  4. tesis
    Replies:
    2
    Views:
    1,186
    Mark Fitzpatrick
    Oct 12, 2008
  5. kj
    Replies:
    5
    Views:
    99
    Bart Lateur
    Feb 11, 2004
Loading...

Share This Page