Looking for feedback on implementation approach

B

Bijoy Naick

I've made multiple posts re different aspects of dynamically adding web and
user controls.. First off, thx for all the responses.. I think I've figured
it out.

I am looking for some feedback on how I am implementing certain
functionlity.. Details follow..

Scenario
======

The application allows users to create new reports to the application. For
each report, there can be multiple delivery channels. For example, Word Doc,
PDF, HTML. Real Media etc. New delivery channels can be added at any time.
Delivery channels are of 2 types; some are strictly links, others can be
links and downloadble. For example,

Report Name : My Report
Delivery Channels : Word, Real Media

For Word, there will be a text box for URL and a FileInput (if its
downloadable from our server)
For Real Media there will only be a textbox for URL

Once a user enters a new report, they are sent to a screen which lists the
various delivery channels. Here they get to specify which delivery channels
apply for the report. Given that the delivery channels will change over
time, I am adding input controls on the fly based on the list of delivery
channels in the db.

For example, for Word I generate a textbox control like this : <input
name="txt_1" type="text" id="txt_1" /> (this is the HTML generated by the
web server control, assume ID of Word is 1).

For Streaming, I would generate <input name="txt_3" type="text" id="txt_3"
/><input name="fileUpload_3:fileToUpload" id="fileUpload_3_fileToUpload"
type="file" /> (Assume ID for Streaming is 3, the fileUpload is a user
control I've created to manage file uploads).

Reading Data
=========

when it comes to storing the data entered by the user, the Save_Click event
is implemented as follows:

- obtain list of valid delivery channel IDs
- do a Page.FindControl("txt_" & id) and Page.FindControl("fileUpload_" & id
& "_fileToUpload") to find the control for the channel IDs.
- read the data and write to the DB.

Does this approach make sense? Are there better/ more efficient ways to make
this happen?

Thx.

Bijoy
(apologies for the lengthy post)
 
J

Jeffrey Palermo [MCP]

Bijoy,
If that works, go for it. You should always implement the simplest
solution that will work; however, I would do on thing a bit differently.
Instead of depending on the id's to find the controls, keep references to
the controls when you dynamically add them. Then you can reference them
more easily in the event handlers. You can have just a ControlCollection
member variable that holds references to these controls.

If what I said above doesn't make any sense, then just go with what you
know. :)

Best regards,
Jeffrey Palermo
 

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
474,301
Messages
2,571,550
Members
48,309
Latest member
jack7878

Latest Threads

Top