Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Inline Expressions

Inline Expressions

Scheduled Pinned Locked Moved ASP.NET
htmldatabasesysadmindebugging
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    OldDog Net
    wrote on last edited by
    #1

    I'm in the process of adapting an article, "Maintain Scroll Position in any Page Element" By Jim Ross, over at ASP Alliance. It's my first exposure to inline expressions, <%= %>. The code for my DIV tag where the scrolling takes place is: DIV id=divAttributeType title="Attribute Type" style="Z-INDEX: 104; LEFT: 16px; BEHAVIOR: url(RetainScrollPosition.htc); OVERFLOW: auto; WIDTH: 936px; POSITION: absolute; TOP: 232px; HEIGHT: 200px" runat="server" ms_positioning="GridLayout" persistID="<%= hidDivAttributeTypeScrollPosition.id%>" scrollPos="<%= 5 %>" persistID and scrollPos are properties defined in the HTML Component file referred to in the style's BEHAVIOR attribute. hidDivAttributeTypeScrollPosition is a hidden INPUT field. I set a breakpoint in one of the client-side scripts defined in the .htc file. When I look at the contents of these two "custom" properties, persistID and scrollPos, the contents are the literal values of the inline expressions i.e. "<%= hidDivAttributeTypeScrollPosition.id%>" and "<%= 5 %>" rather than the expected "hidDivAttributeTypeScrollPosition" and "5". When I hard code the name of the INPUT control the solution works wonderfully :-D but I've spent the last four hours trying to figure out why the inline expressions don't appear to be executed. Is there some switch the turns this sort of processing on and off. I'm stumped! X| Thanks, Will

    M 1 Reply Last reply
    0
    • O OldDog Net

      I'm in the process of adapting an article, "Maintain Scroll Position in any Page Element" By Jim Ross, over at ASP Alliance. It's my first exposure to inline expressions, <%= %>. The code for my DIV tag where the scrolling takes place is: DIV id=divAttributeType title="Attribute Type" style="Z-INDEX: 104; LEFT: 16px; BEHAVIOR: url(RetainScrollPosition.htc); OVERFLOW: auto; WIDTH: 936px; POSITION: absolute; TOP: 232px; HEIGHT: 200px" runat="server" ms_positioning="GridLayout" persistID="<%= hidDivAttributeTypeScrollPosition.id%>" scrollPos="<%= 5 %>" persistID and scrollPos are properties defined in the HTML Component file referred to in the style's BEHAVIOR attribute. hidDivAttributeTypeScrollPosition is a hidden INPUT field. I set a breakpoint in one of the client-side scripts defined in the .htc file. When I look at the contents of these two "custom" properties, persistID and scrollPos, the contents are the literal values of the inline expressions i.e. "<%= hidDivAttributeTypeScrollPosition.id%>" and "<%= 5 %>" rather than the expected "hidDivAttributeTypeScrollPosition" and "5". When I hard code the name of the INPUT control the solution works wonderfully :-D but I've spent the last four hours trying to figure out why the inline expressions don't appear to be executed. Is there some switch the turns this sort of processing on and off. I'm stumped! X| Thanks, Will

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, Basically, you cannot use a code render block[^] (inline expressions, <%= %> ) to set a value for the property of an element with the runat="server". In this case, there are a couple of ways to set the value: + Use an inline expression and comment out the stuff runat="server". + Add the runat="server", and use a data binding expression[^] <%# %> , remember to call the Page.DataBind method so that the value of the expression can be populated and assigned to the property. + Add the runat="server", and assign a value to the property in the server side code:

      O 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, Basically, you cannot use a code render block[^] (inline expressions, <%= %> ) to set a value for the property of an element with the runat="server". In this case, there are a couple of ways to set the value: + Use an inline expression and comment out the stuff runat="server". + Add the runat="server", and use a data binding expression[^] <%# %> , remember to call the Page.DataBind method so that the value of the expression can be populated and assigned to the property. + Add the runat="server", and assign a value to the property in the server side code:

        O Offline
        O Offline
        OldDog Net
        wrote on last edited by
        #3

        Ahhhhh, thanks SO much. I think at some point I was chasing a spelling error and added the runat="server" so that I could track it with Intellisense in the Code-Behind and then left it in there. Is there any chance that you could point me to somewhere that this is documented so that I can fully understand it rather than just incorporate it into my collection of dogma? Thanks again, Will

        M 1 Reply Last reply
        0
        • O OldDog Net

          Ahhhhh, thanks SO much. I think at some point I was chasing a spelling error and added the runat="server" so that I could track it with Intellisense in the Code-Behind and then left it in there. Is there any chance that you could point me to somewhere that this is documented so that I can fully understand it rather than just incorporate it into my collection of dogma? Thanks again, Will

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          You can consult it in MSDN[^], the book about ASP.NET written by Dino Esposito is also a good resource.

          O 1 Reply Last reply
          0
          • M minhpc_bk

            You can consult it in MSDN[^], the book about ASP.NET written by Dino Esposito is also a good resource.

            O Offline
            O Offline
            OldDog Net
            wrote on last edited by
            #5

            Been there and there, tried them (way before I asked believe it or not). There is WAY to much information in this environment that is not available without going spelunking. I've got a library of 17 books just on ADO.Net, ASP.Net, C#, the Framework, DHTML & Javascript. (At about $50 pop (list anyway) and all are about to be obsoleted by .Net 2.) Most of them seem to completely ignore a lot of the difficult and distasteful stuff. The Internet resources do a great job of sharing information and techniques but seldom point to any underlying documentation. The search for documentation combined with trial-and-error are HUGELY inefficient time-wise. Damn, I miss IBM software and documentation! I guess, as they say, "You guys get the big bucks". I think I'm going to post this on the "Rants" forum. Thanks again. Will

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups