Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

How to add HTML <BR> spaces when you add a dynamic button to Accordion Pane

Ok I have an Accordion Panel in my VB.NET (asp/web) project. I dynamically add a number of buttons and labels with the following code (amount defined my data in SQL):

I am populating the Accordion dynamically using SQL DB data during the Page_Load server event. Buttons are added to the pane like this:

   Private Sub addBtn(ByVal acp As AjaxControlToolkit.AccordionContentPanel, ByVal btnLabel As String)
        'Adds a button to an Accordion Content Panel
        Dim btn As New Button
        btn.Text = btnLabel
        acp.Controls.Add(btn)
        Dim myLBL as new Label
        mylbl.text = mDate.tostring 'Date from var passed in via SQL
        AddHandler btn.Click, AddressOf BtnClick
    End Sub

I have a list of jobs with a jobID, I have the jobID appear in a button added just as yours on my accordion. However I also add the date of the job as a label next to each button. This works, buttons and labels get added except they are exactly after the previous control so the layout looks a mess. What I want is all the buttons going down on the left and the date label to its corresponding buttons right.

I think this can be done if I was able to addin a HTML <BR> after each control is added to the HTML but how do I do this, is there a control for just HTML, how do I add this dynamically, can anyone tell me a better way, perhaps using styles, although even then im unsure how to go about it.

Any help appreciated. Thanks in advance.

James.
0
Steve_Buck
Asked:
Steve_Buck
2 Solutions
 
Anurag AgarwalPython DeveloperCommented:
What you can do is add whole HTML into this acp.

First add HTMLTable then TR & TD. For all this you will find corresponding HTML Controls under System.UI.HtmlControls namespace.

this way you will able to add each button & label combination on different  TD

Anurag
0
 
ajitha75Commented:
You can insert a break tag as below

        HtmlGenericControl breakctl = new HtmlGenericControl();
        breakctl.InnerHtml = "<br/";
        pnltest.Controls.Add(breakctl);
0
 
Steve_BuckAuthor Commented:
Thanks Guys,

This sorted me out! :D
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now