Databinding a custom user control

Discussion in 'ASP .Net Building Controls' started by Scott, Dec 4, 2003.

  1. Scott

    Scott Guest

    I am having trouble getting a web user control that I
    created to work the way I need it to in my ASP.NET app (I
    am using VB for the script). I am doing a survey (Q&A)
    type application where I need to create custom 'text
    boxes' so as a first step I created a ascx file with a
    text box in it (just to make it simple) and added a
    property called 'textValue' and hooked up the get and let
    parts. Then I created a form that references the control
    and placed the control in a datalist control's
    <itemTemplate> tag. The good news is that this works as
    long as I write the line of code as follows:

    <ma:tbControl id="item1" runat"server"
    textValue="hard coded text!"/>

    I can also write the following line of code immediately
    after and it will return the questions from the dataset
    just fine (although not in the control I designed):

    <%# Databinder.eval(Container.dataitem, "question") %>

    The problem is that when I try to combine the 2 lines to
    send the string from the 'question' field into
    the 'textValue' property of the tbControl...

    <ma:tbControl id="item1" runat"server" textValue="<%#
    Databinder.eval(Container.dataitem, "Question")%>"/>

    ....I get the error message:

    "The server tag is not well formed"

    What am I doing wrong? <also, I will need to save this
    data once I get this figured out, so any thoughts you can
    offer on that would be helpful.> :)

    Scott
    Scott, Dec 4, 2003
    #1
    1. Advertising

  2. Scott

    MSFT Guest

    Hi Scott,

    You may try to change the code to:

    <ma:tbControl id="item1" runat=server textValue='<%#
    Databinder.eval(Container.dataitem, "Question")%>' />

    Then, will it work?

    Luke
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    MSFT, Dec 5, 2003
    #2
    1. Advertising

  3. Scott

    Torp Guest

    Yes! That works! Thank you! It was so simple... I guess I was just beat
    after working the app all day. Thanks!

    Now that I am able to do this, I have another question that is related:

    It would be best if I could design the control (for use on an ASP.NET page)
    to work identically to the system.web.ui.page controls (or any other
    framework inherited control). For example, I would like to use "imports"
    and "inherits" to reference the control instead of the "<%@ register
    tagprefix="ma"....". I would also potentially like to create other controls
    in a 'library' just like the CLR does so I can just reference my set one
    time with "imports" and then pick the control I want to use
    programmatically. The method I am using now will let me create one control
    at a time in a seperate ascx file and then I have to reference them all with
    seperate lines on the aspx page. A real messy thing to do!

    Is there a better way to do this? Even if you just point me to a tech doc,
    I would greatly appreciate it.

    Thanks,

    Scott

    "MSFT" <> wrote in message
    news:...
    > Hi Scott,
    >
    > You may try to change the code to:
    >
    > <ma:tbControl id="item1" runat=server textValue='<%#
    > Databinder.eval(Container.dataitem, "Question")%>' />
    >
    > Then, will it work?
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    Torp, Dec 5, 2003
    #3
  4. Scott

    Scott Guest

    Yes! That works! Thank you! It was so simple... I guess I was just beat
    after working the app all day. Thanks!

    Now that I am able to do this, I have another question that is related:

    It would be best if I could design the control (for use on an ASP.NET page)
    to work identically to the system.web.ui.page controls (or any other
    framework inherited control). For example, I would like to use "imports"
    and "inherits" to reference the control instead of the "<%@ register
    tagprefix="ma"....". I would also potentially like to create other controls
    in a 'library' just like the CLR does so I can just reference my set one
    time with "imports" and then pick the control I want to use
    programmatically. The method I am using now will let me create one control
    at a time in a seperate ascx file and then I have to reference them all with
    seperate lines on the aspx page. A real messy thing to do!

    Is there a better way to do this? Even if you just point me to a tech doc,
    I would greatly appreciate it.

    Thanks,

    Scott

    "MSFT" <> wrote in message
    news:...
    > Hi Scott,
    >
    > You may try to change the code to:
    >
    > <ma:tbControl id="item1" runat=server textValue='<%#
    > Databinder.eval(Container.dataitem, "Question")%>' />
    >
    > Then, will it work?
    >
    > Luke
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    Scott, Dec 5, 2003
    #4
  5. Scott

    MSFT Guest

    MSFT, Dec 8, 2003
    #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. Replies:
    0
    Views:
    426
  2. =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=

    Databinding to custom properties of a custom class in ASP.NET 2

    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    578
    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=
    Apr 20, 2005
  3. jobs
    Replies:
    0
    Views:
    1,595
  4. Matt Sokol
    Replies:
    2
    Views:
    365
    Theo Tillotson
    Aug 7, 2003
  5. Earl Teigrob
    Replies:
    1
    Views:
    387
    Shravan
    Mar 1, 2004
Loading...

Share This Page