Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Databinding a custom user control

Reply
Thread Tools

Databinding a custom user control

 
 
Scott
Guest
Posts: n/a
 
      12-04-2003
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
 
Reply With Quote
 
 
 
 
MSFT
Guest
Posts: n/a
 
      12-05-2003
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.)

 
Reply With Quote
 
 
 
 
Torp
Guest
Posts: n/a
 
      12-05-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.)
>



 
Reply With Quote
 
Scott
Guest
Posts: n/a
 
      12-05-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.)
>



 
Reply With Quote
 
MSFT
Guest
Posts: n/a
 
      12-08-2003
Hi Scott,

You may try to create a " Web Control Library" project to see if it is what
you want. For more information on ASP.NET server controls, you may refer to:

INFO: ASP.NET Server Controls Overview
http://support.microsoft.com/default...;EN-US;Q306459

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom User Control is not rendered inside another user control in a server table. Leeor Chernov ASP .Net 2 10-16-2005 08:35 AM
Databinding to custom properties of a custom class in ASP.NET 2 =?Utf-8?B?SW1hciBTcGFhbmphYXJz?= ASP .Net 0 04-20-2005 07:34 PM
Databinding in a user control that contains another user control StraussGuy@hotpop.com ASP .Net 0 01-07-2005 04:55 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments