473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Generate Web Controls Dynamically?

WB
Hi,

How can I generate web controls such as textboxes and drop-menus on the fly?

My web application allows users to fill out PDF forms online. There are many
PDF forms, and my application reads the fields in the user's chosen PDF file,
displays a webform with relevant fields (textbox or drop-menu or radio
buttons etc) for user to fill out online. I'm using a 3rd party software to
read and write to the PDF file, but I don't know how to generate the webform
on the fly and subsequently extract the values.
YWB.
Jan 25 '06 #1
4 1872
One of the simplest solutions will be creating ALL possible controls in the
design with Viisible property set to false, and then only make visible those
that are requested by the User. This way you will always be able to read
values of your controls. If you want a bit more elegant (from the user's
perspective) solution, you can create a table where each row will contain
both label and control to fill in, and make table rows server side html
controls. Then, similar to the previous scenario, only make visible those
rows controls for which have been requested by User.

"WB" wrote:
Hi,

How can I generate web controls such as textboxes and drop-menus on the fly?

My web application allows users to fill out PDF forms online. There are many
PDF forms, and my application reads the fields in the user's chosen PDF file,
displays a webform with relevant fields (textbox or drop-menu or radio
buttons etc) for user to fill out online. I'm using a 3rd party software to
read and write to the PDF file, but I don't know how to generate the webform
on the fly and subsequently extract the values.
YWB.

Jan 25 '06 #2
WB
Hi,

It's not practical for me to create ALL possible controls 'cuz my web
application has to deal with hundreds of PDF files with different fields and
these files are constantly updated.

I think ideally I'd like to have something like your second suggestion. I'd
like to have a table (DataGrid?) and the application will read the related
PDF file during run time, grab all the field names with the 3rd party
software and save these names into an array. Then I'll display a webform in
the table, and add row by row for each element in the field name array and
put a text-box / drop-menu in each row. And upon postback, I'll extract the
value from each control...

But how can I do this?

ywb.
"Sergey Poberezovskiy" wrote:
One of the simplest solutions will be creating ALL possible controls in the
design with Viisible property set to false, and then only make visible those
that are requested by the User. This way you will always be able to read
values of your controls. If you want a bit more elegant (from the user's
perspective) solution, you can create a table where each row will contain
both label and control to fill in, and make table rows server side html
controls. Then, similar to the previous scenario, only make visible those
rows controls for which have been requested by User.

"WB" wrote:
Hi,

How can I generate web controls such as textboxes and drop-menus on the fly?

My web application allows users to fill out PDF forms online. There are many
PDF forms, and my application reads the fields in the user's chosen PDF file,
displays a webform with relevant fields (textbox or drop-menu or radio
buttons etc) for user to fill out online. I'm using a 3rd party software to
read and write to the PDF file, but I don't know how to generate the webform
on the fly and subsequently extract the values.
YWB.

Jan 26 '06 #3
WB,

Not trying to scare you - but the way you chose is at least a few days of
hard work...

In general, you create a DataGrid with 1 column being a label, and the
second - template column that contains a set of standard controls - 1
textbox, 1 combo (we omit others, like radiobuttonlist, for simplicity). Then
in DataGrid.ItemCreated event for item rows where
e.Item.ItemType.ToString().IndexOf("Item") > -1 you make relevant controls
visible, something similar to the following:

TableCell cell = e.Cells[myControlsCellsOrdinal];
foreach (Control ctl in cell.Controls)
{
ctl.Visible = false;
if (ctlType.GetType().Name == myTypeFromDatabase)
{
ctl.Visible = true;
if (ctl is TextBox)
((TextBox)ctl).Text = myValueFromDatabase;
else if (ctl is ....
}
}

You take the row from your feeding table of e.Item.ItemIndex to get your
database values.

Then on the postback, you read Items collection of your datagrid to and
check visible controls to retrieve the values posted by the user.

That is a very exciting exercise that you chose.'

Good luck!

"WB" wrote:
Hi,

It's not practical for me to create ALL possible controls 'cuz my web
application has to deal with hundreds of PDF files with different fields and
these files are constantly updated.

I think ideally I'd like to have something like your second suggestion. I'd
like to have a table (DataGrid?) and the application will read the related
PDF file during run time, grab all the field names with the 3rd party
software and save these names into an array. Then I'll display a webform in
the table, and add row by row for each element in the field name array and
put a text-box / drop-menu in each row. And upon postback, I'll extract the
value from each control...

But how can I do this?

ywb.
"Sergey Poberezovskiy" wrote:
One of the simplest solutions will be creating ALL possible controls in the
design with Viisible property set to false, and then only make visible those
that are requested by the User. This way you will always be able to read
values of your controls. If you want a bit more elegant (from the user's
perspective) solution, you can create a table where each row will contain
both label and control to fill in, and make table rows server side html
controls. Then, similar to the previous scenario, only make visible those
rows controls for which have been requested by User.

"WB" wrote:
Hi,

How can I generate web controls such as textboxes and drop-menus on the fly?

My web application allows users to fill out PDF forms online. There are many
PDF forms, and my application reads the fields in the user's chosen PDF file,
displays a webform with relevant fields (textbox or drop-menu or radio
buttons etc) for user to fill out online. I'm using a 3rd party software to
read and write to the PDF file, but I don't know how to generate the webform
on the fly and subsequently extract the values.
YWB.

Jan 26 '06 #4
Add an <asp:Placeholder id="myPlaceholder" etc

In code:
Placeholder myPlaceholder = Page.FindControl("myPlaceholder");

in Form_Load:
TextBox txt = new TextBox();
txt.ID = idstring;
myPlaceholder.Controls.Add(txt)

in PostBack:
string myValue = Request.Form["TextBox1"];

HTH

"WB" <WB@discussions.microsoft.com> wrote in message
news:3E**********************************@microsof t.com...
Hi,

How can I generate web controls such as textboxes and drop-menus on the
fly?

My web application allows users to fill out PDF forms online. There are
many
PDF forms, and my application reads the fields in the user's chosen PDF
file,
displays a webform with relevant fields (textbox or drop-menu or radio
buttons etc) for user to fill out online. I'm using a 3rd party software
to
read and write to the PDF file, but I don't know how to generate the
webform
on the fly and subsequently extract the values.
YWB.

Mar 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nick | last post by:
Hi, I would like to create asp.net controls with ID names generated dynamically, such as from within a loop to create names like "C1" "C2" "C3" "C4" ... and so on. For example, I would like to...
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
2
by: Martin | last post by:
Hi, I need to create the html below with dynamic controls <span class="myclass"> <h3>text1</h3> <h4><span>Price <strong>text2</strong> | Duration <strong>text3</strong></span></h4> </span>
0
by: Avon | last post by:
Hi friends, I am very sorry for my not perfect English. I have one question, I am using David Bauer's DynamicControlsPlaceholder to dinamically generate controls and I am tryig to generate...
1
by: Scott Zabolotzky | last post by:
I'm sure somebody has to have done this already but I can't find any good references. If I have an XML file with an associated XSD what is the best way to dynamically generate a web form with...
5
by: sean.gilbertson | last post by:
Hi, I'm sort of new to ASP.NET 2.0 and ASP.NET in general. I have some data that I would like to display in a tabular format, but I'm going to be generating the columns dynamically, and I would...
2
by: =?Utf-8?B?aUhhdkFRdWVzdGlvbg==?= | last post by:
I have a dropdown with the list of items from 1 to 6 Below the dropdown there is a table(This table contains all textbox and dropdownlist) with 6 rows and 5 cloums, which is INVISIBLE by default. ...
2
by: | last post by:
Hi, I have 2 scenarios: First, an aspx page that contains 300 controls with the labels of course in a table. Second, an empty aspx page that contains on loading a script that creates the 300...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.