Post Back and HTML Controls

C

Chris

Hello.

I had a question that I was hoping someone might be able
to answer.

I have an ASP .NET Web Form with a custom control that
generates HTML based on certain criteria.

This control is on the web form. For example the control
will generate a question with an HTML input text box.

When my web form does a post how do I get the contents of
this text box?

When I do request.form.item("txtTextBox") it returns
nothing.

In the HTML of the web form the input text box shows-up
but I can't obtain the contents. Does someone know what
I'm doing wrong?

Thanks for your time,
Chris
 
K

Kevin Spencer

It's a custom control. Only you know how you wrote it to work.

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
B

bruce barker

it depends on how you rendered the html text box.

if you rendered the html yourself, you must include a unique name attribute
that can be used to look it up in the form collection.

if you added a html text box control, it assigned a unique name based on the
id you gave it. generally
<your controls id>:<textbox id>
if you regen the control on postback (before form load), you can just ask
the subcontrol for its value.

-- bruce (sqlwork.com)
 
G

Guest

on the control render I write out HTML
Protected Overrides Sub Render(ByVal output As
System.Web.UI.HtmlTextWriter)
If Me.Action = "register" Then
output.Write(getHTML)
ElseIf Me.Action = "confirm" Then
output.Write(getConfirmHTML)
End If
End Sub

The HTML that gets written is:
..Append("<TR><TD>")
..Append("&nbsp&nbspWhat is your clients's last name?
&nbsp&nbsp" & "</TD>" & vbCrLf)
..Append("<TD><INPUT id=" & """txtClientsName""" & "
type=" & """text""" & "><BR></TD></TR>" & vbCrLf)

simple question with a text box

My question is do I need to add a property within the
control to save the value or once the HTML is written to
the screen it now becomes part of the web form.

I'm trying to understand the process so I can obtain the
value of the control text box field.

Web form -> control -> write HTML output -> becomes part
of Web form and is rendered within table -> on post what
do I need to do to obtain the value?

Thanks
 

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

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top