asp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ani

    asp

    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:radiobutto nlist> 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!
  • Esteban Felipe

    #2
    asp

    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.A dd(myCheckBox);

    Page, DataGrid, Table, PlaceHolders, etc.. are all
    containers.[color=blue]
    >-----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.[/color]
    I[color=blue]
    >am concatenating all the radio button items in a function
    >in my class. The function returns the concatenated text[/color]
    (in[color=blue]
    >the form of string) to the UI page . I am using asp
    >controls like <asp:radiobutto nlist> 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!
    >.
    >[/color]

    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: asp

      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.Control s.Add(myDynamic Control);

      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 = GetDataSetForSt ates();
      rbl.DataBind();

      pnlOutput.Contr ols.Add(lbl);
      pnlOutput.Contr ols.Add(rbl);


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

      *************** *************** *************** *************** **********
      Think Outside the Box!
      *************** *************** *************** *************** **********
      "ani" <anonymous@disc ussions.microso ft.com> wrote in message
      news:08ee01c39c 99$7d8f0480$a60 1280a@phx.gbl.. .[color=blue]
      > 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:radiobutto nlist> 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![/color]



      Comment

      Working...