Why do I get an error when I put inline code in a web control custom atribute?

Discussion in 'ASP .Net Web Controls' started by jahles, Aug 28, 2003.

  1. jahles

    jahles Guest

    I have a control that takes an ID (short). In the html where the control is
    placed, when I put the following:

    <td>
    <cc2:logocontrol id="Logocontrol1"
    <TiltleID="<%=_somec#variablethatisetearlier%>
    runat="server">
    </cc2:logocontrol>
    </td>

    When I run the page, I get an error saying i can't have '<% %>' with server
    side controls. How can I pass in a run time variable here? When I try to set
    this variable in the code behind for PAGE_LOAD it doesn't seem to have any
    affect. I need to be able to set this variable 'on the fly' somewhere!


    Thanks in advance
    j
     
    jahles, Aug 28, 2003
    #1
    1. Advertising

  2. jahles

    Ken Schaefer Guest

    You could create a property in your User Control, and set the property's
    value at run time. In the user control you could then have a literal control
    (or similar), which is set to the value of the property.

    Cheers
    Ken

    "jahles" <> wrote in message
    news:bijk51$c0g$...
    : I have a control that takes an ID (short). In the html where the control
    is
    : placed, when I put the following:
    :
    : <td>
    : <cc2:logocontrol id="Logocontrol1"
    : <TiltleID="<%=_somec#variablethatisetearlier%>
    : runat="server">
    : </cc2:logocontrol>
    : </td>
    :
    : When I run the page, I get an error saying i can't have '<% %>' with
    server
    : side controls. How can I pass in a run time variable here? When I try to
    set
    : this variable in the code behind for PAGE_LOAD it doesn't seem to have any
    : affect. I need to be able to set this variable 'on the fly' somewhere!
    :
    :
    : Thanks in advance
    : j
    :
    :
     
    Ken Schaefer, Aug 28, 2003
    #2
    1. Advertising

  3. jahles

    Teemu Keiski Guest

    It could work if you'd use databinding syntax:

    <TitleID='<%#variable%>'

    (note single quotes)

    and it is evaluated/set when DataBind is called either for the Page,
    containing control, or this control.

    --
    Teemu Keiski
    MCP,Designer/Developer
    Mansoft tietotekniikka Oy
    http://www.mansoft.fi

    AspInsiders Member, www.aspinsiders.com
    ASP.NET Forums Moderator, www.asp.net
    AspAlliance Columnist, www.aspalliance.com

    "jahles" <> kirjoitti viestissä
    news:bijk51$c0g$...
    > I have a control that takes an ID (short). In the html where the control

    is
    > placed, when I put the following:
    >
    > <td>
    > <cc2:logocontrol id="Logocontrol1"
    > <TiltleID="<%=_somec#variablethatisetearlier%>
    > runat="server">
    > </cc2:logocontrol>
    > </td>
    >
    > When I run the page, I get an error saying i can't have '<% %>' with

    server
    > side controls. How can I pass in a run time variable here? When I try to

    set
    > this variable in the code behind for PAGE_LOAD it doesn't seem to have any
    > affect. I need to be able to set this variable 'on the fly' somewhere!
    >
    >
    > Thanks in advance
    > j
    >
    >
     
    Teemu Keiski, Aug 28, 2003
    #3
    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. Jerry Manner
    Replies:
    4
    Views:
    709
    Jonathan N. Little
    Jun 25, 2005
  2. ocelka
    Replies:
    2
    Views:
    409
    Romin
    Mar 18, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,125
    Smokey Grindel
    Dec 2, 2006
  4. gtb

    Atribute error

    gtb, Apr 26, 2007, in forum: Python
    Replies:
    2
    Views:
    259
  5. Bart

    property atribute does not work

    Bart, Dec 15, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    122
Loading...

Share This Page