[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Locating a button BELOW a dynamically-generated control

Posted on 2007-10-18
3
Medium Priority
?
272 Views
Last Modified: 2013-11-07
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()));

0
Comment
Question by:CAWhite
  • 2
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 20101638
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
 

Author Comment

by:CAWhite
ID: 20101661
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
 

Author Comment

by:CAWhite
ID: 20101684
Hi Bob,

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


0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question