Locating a button BELOW a dynamically-generated control

I may have bricked myself into a corner here by saying, "Sure, that's no problem !"

My C# Framework 2.0 app I'm building with VS 2005 reads a policy document on our sister organization's site for display on our own site.  The document originates as a Word doc at the other organization's URL; my page reads it via StreamReader (since my boss said no to iFrames and security policy won't allow us to have Word on the server) into a literal control on my page.  

My boss wants me to move the button to page bottom--for a bit of assurance users have read the policy before signing via button click.  

Trying to relocate the button, I encountered the problem: Having the button at page top--with the dynamically-generated literal control below--is not the same as putting the button below this created-on-the-fly control.  In the latter case, which my boss wants, I see  the button's HTML code if I use View Source--but no button appears in presentation.

I'm a C# newbie.  Is there maybe a late-binding solution or other expedient way to get that button to appear below the policy before we demo for the director ?  Could I put some sort of placeholder on the page that could grow, and locate the button below at design time?

Your counsel appreciated.





From Page Load:

   
            //the string "sbuild" compiled from the doc goes into the literal control

            frmSignIt.Controls.Add(new System.Web.UI.LiteralControl(sbuild.ToString()));


            //Now that the dynamic-content control is generated, I guess I should put the button after it
            //sequentially in the code (I already tried having it in the .aspx file, but that only works if
            //the button is to appear ABOVE the policy; I need it below)

            string strButton =
                  "<center><asp:Button ID=\"btnSignIt\" runat=\"server\" Text = \"I have read and accept the terms of the Policy\" OnClick = \"btnSignIt_Click\" ></asp:Button> </center>"                
                ;
           
            frmSignIt.Controls.Add(new System.Web.UI.LiteralControl(strButton.ToString()));

CAWhiteAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
You could use the Controls.AddAt(index, control) instead of the Add, and Controls.IndexOf to find the index of the control that you want to add the control after.

Bob
0
 
CAWhiteAuthor Commented:
Never mind.  Yes, there's a placeholder available--the literal control itself.  I had just learned about the control , and hadn't understood I could place a declaration in the aspx rather than adding it dynamically from the codebehind.  

Sheesh.
0
 
CAWhiteAuthor Commented:
Hi Bob,

Sorry I posted without having seen your comment yet.    That gives me more than one way to do this, thanks !


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.