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. Advertisements

  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. Advertisements

  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. Advertisements

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. =?Utf-8?B?SldoaXR0ZWQ=?=

    Custom Control That Accepts Inline Code

    =?Utf-8?B?SldoaXR0ZWQ=?=, Nov 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    480
    =?Utf-8?B?SldoaXR0ZWQ=?=
    Nov 2, 2004
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    1,363
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,825
    Smokey Grindel
    Dec 2, 2006
  4. gtb

    Atribute error

    gtb, Apr 26, 2007, in forum: Python
    Replies:
    2
    Views:
    351
  5. Gabriel Rossetti
    Replies:
    3
    Views:
    791
    Jerry Hill
    Apr 25, 2008
  6. Matt Sokol
    Replies:
    2
    Views:
    618
    Theo Tillotson
    Aug 7, 2003
  7. JWhitted

    Custom Control that accepts Inline Code

    JWhitted, Nov 1, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    283
    Nathan Wilkes
    Nov 8, 2004
  8. Deniz Miscioglu
    Replies:
    1
    Views:
    291
    Deniz Miscioglu
    Oct 19, 2003
Loading...