Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > asp

Reply
 
 
ani
Guest
Posts: n/a
 
      10-27-2003
I need to dynamically load all the controls on to a page.
Most of the controls are either radio buttons or
checkboxes and the web page basically is a questionaire. I
am concatenating all the radio button items in a function
in my class. The function returns the concatenated text(in
the form of string) to the UI page . I am using asp
controls like <asp:radiobuttonlist> while concatenating.
The text is being displayed but not the radio buttons.
Can't I concatenate the asp server controls and return
them as a string ? Why is it the radio buttons are not
being displayed. Please help!
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      10-27-2003
It is likely you are outputting a string that states your intent, but not
the actual controls. The reason is you are outputting client side script for
a server side control. As HTTP is stateless, you are sending garbage text to
the client, which does not understand, as it is intended for server side.

To dynamically add controls, use CodeBehind and some form of Container.
While the Page is a container, it is better to use something like a panel
or table. You can place text, either as a label, or as inner HTML in a table
cell, and you can attach controls. For the panel, it is as simple as:

myPanel.Controls.Add(myDynamicControl);

With a panel, you have to add them in order. For layout, tables are often a
better choice.

When you load the controls, you can bind the "choices" from a database table
to set up your radio buttons, et al.

Quick example (off the cuff, so you may need to alter to have it work):

Label lbl = new Label();
lbl.Text = "Choose a state<br>";

RadioButtonList rbl = new RadioButtonList();
rbl.DataSource = GetDataSetForStates();
rbl.DataBind();

pnlOutput.Controls.Add(lbl);
pnlOutput.Controls.Add(rbl);


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"ani" <> wrote in message
news:08ee01c39c99$7d8f0480$...
> I need to dynamically load all the controls on to a page.
> Most of the controls are either radio buttons or
> checkboxes and the web page basically is a questionaire. I
> am concatenating all the radio button items in a function
> in my class. The function returns the concatenated text(in
> the form of string) to the UI page . I am using asp
> controls like <asp:radiobuttonlist> while concatenating.
> The text is being displayed but not the radio buttons.
> Can't I concatenate the asp server controls and return
> them as a string ? Why is it the radio buttons are not
> being displayed. Please help!




 
Reply With Quote
 
 
 
 
Esteban Felipe
Guest
Posts: n/a
 
      10-27-2003
They are not being displayed because they haven't being
processed... Trying creating the controls and adding them
in a container like "Page":
CheckBox myCheckBox = new CheckBox();
myCheckBox.Text = "xxx";
Page.Controls.Add(myCheckBox);

Page, DataGrid, Table, PlaceHolders, etc.. are all
containers.
>-----Original Message-----
>I need to dynamically load all the controls on to a page.
>Most of the controls are either radio buttons or
>checkboxes and the web page basically is a questionaire.

I
>am concatenating all the radio button items in a function
>in my class. The function returns the concatenated text

(in
>the form of string) to the UI page . I am using asp
>controls like <asp:radiobuttonlist> while concatenating.
>The text is being displayed but not the radio buttons.
>Can't I concatenate the asp server controls and return
>them as a string ? Why is it the radio buttons are not
>being displayed. Please help!
>.
>

 
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
global filter to redirect asp (old asp!) pages on asp.net site Daves ASP .Net 2 05-31-2006 08:33 AM
2.0: asp:Menu, asp:XmlDataSource, asp:PlaceHolder R.A.M. ASP .Net 1 03-29-2006 07:55 AM
[ASP.NET1.1]Should I kill the ASP.NET worker process after recompilingmy ASP.NET webservice? Andrea Raimondi ASP .Net 1 02-06-2006 08:10 AM
ASP.Net cookie -> ASP -> ASP.Net Ben ASP .Net 3 05-28-2004 03:35 PM
LOOP through an ASP form's pages (not ASP.NET - ASP classic) David A. Beck ASP General 10 04-13-2004 05:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57