using databinding to codebehind in html

Discussion in 'ASP .Net' started by rjl, Dec 21, 2005.

  1. rjl

    rjl Guest

    How do you use variable in html tag, such as:
    <a href="<%=getVariable%>Test</a>

    thanks.
    rjl, Dec 21, 2005
    #1
    1. Advertising

  2. rjl

    Karl Seguin Guest

    Well, the ASP.Net way would be to make that a server control and access it
    in your page lifecycle:

    <a id="test" runat="server" />

    codebehind:
    Protected test as HtmlAnchor

    sub Page_load(...)
    Test.HRef = "Blah.aspx"
    end sub


    if you insist on doing the <%=getVariable%> route, you'll need to define
    getVariable as a protected string.

    karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "rjl" <> wrote in message
    news:...
    > How do you use variable in html tag, such as:
    > <a href="<%=getVariable%>Test</a>
    >
    > thanks.
    >
    Karl Seguin, Dec 21, 2005
    #2
    1. Advertising

  3. rjl

    rjl Guest

    thanks, but I ahve dont that and it won't work, If I place the variable
    on hte page (outside the tag description), it does render properly.
    Thanks,
    rjl, Dec 22, 2005
    #3
  4. rjl

    Karl Seguin Guest

    How and where is the variable declared? Is this inside a
    repeater/datalist/datagrid?

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "rjl" <> wrote in message
    news:...
    > thanks, but I ahve dont that and it won't work, If I place the variable
    > on hte page (outside the tag description), it does render properly.
    > Thanks,
    >
    Karl Seguin, Dec 22, 2005
    #4
  5. rjl

    rjl Guest

    it is a property in code behind (String)
    rjl, Dec 22, 2005
    #5
  6. rjl

    Karl Seguin Guest

    Karl Seguin, Dec 22, 2005
    #6
  7. rjl

    rjl Guest

    public.
    rjl, Dec 24, 2005
    #7
  8. rjl

    Karl Seguin Guest

    Any time you might want to provide code :)

    Are you sure it's being set ? When is it being set? If you are trying to
    use it within a bound control (repeater, datalist, datagrid...), you might
    need to use %# instead of %=

    <a href='<%#getVariable%>'>Test</a>


    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



    "rjl" <> wrote in message
    news:...
    > public.
    >
    Karl Seguin, Dec 24, 2005
    #8
    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. Alex Papadimoulis
    Replies:
    3
    Views:
    3,543
    Leo Muller
    May 6, 2004
  2. Replies:
    1
    Views:
    2,896
  3. jobs
    Replies:
    0
    Views:
    1,599
  4. Earl Teigrob
    Replies:
    1
    Views:
    394
    Shravan
    Mar 1, 2004
  5. Prince Mathew

    URGENT-DataBinding expression in the codebehind

    Prince Mathew, Jan 26, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    136
    Prince Mathew
    Jan 26, 2005
Loading...

Share This Page