Databinding a custom user control

S

Scott

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
 
M

MSFT

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.)
 
T

Torp

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
 
S

Scott

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top