CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2010
    Posts
    130

    [RESOLVED] Layout turns funny after MessageBox appears!

    I try to extract data from a database and if there are records in the database I display these in a table. If there are none then I dont display any table and a dialogbox pops up stating that there are no records in the db. The messagebox however causes my layout to go funny! The attachment Beurteilungsbogen2.gif shows what my layout looks like if I comment out the messagebox (as you can see just an empty table appears in the middle of the screen) while Beurteilungsbogen.gif shows that my header has gone all over the place after my messagebox has popped up!! I have created my layout in CSS. Is there a way to stop this happening?
    Attached Images Attached Images   

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Layout turns funny after MessageBox appears!

    Can you show us the CSS code in question ¿

  3. #3
    Join Date
    Jan 2010
    Posts
    130

    Post Re: Layout turns funny after MessageBox appears!

    My CSS Style sheet is really long... I only included the CSS for the page in question and for the masterpage that it derives from:

    Code:
    /* MASTER PAGE */
    body {
        background-color: #dedede;
        font-family: Arial;
        font-size: 12px;
        text-align:left; 
    }
    .navigation {
        height: 24px;
        margin-left: 0px;
        background-color: #FFF;
        border-top: solid 1px #3A9DCB;
        border-bottom: solid 2px #3A9DCB;
    }
    .nav_btn2 {
    	position: relative;
    	left: -35px;
    }
    .nav_btn3 {
    	position: relative;
    	left: -68px;
    }
    .nav_btn4 {
    	position: relative;
    	left: -102px;
    }
    .nav_btn5 {
    	position: relative;
    	top: -28px;
    	left: 478px;
    }
    .nav_btn6 {
    	position: relative;
    	float: right;
    	top: -28px;
    	right: 0px;
    }
    .head {
        height: 114px;
        width:  768px;
        background-color: #FFF; 
    }
    .main {
        height: 586px;
        width:  768px;
        margin-left: auto;
        margin-right:  auto;       
        border: solid 1px #000;  
    }
    .title {
    	width: 500px;
    	border: none;
    	color: #3a9dcb;
    	padding-top: 10px;
    	font-weight: bold;
    	font-size: 14px;
    	float: left;
     }
    .footer {
        height: 20px;
        max-width: 768px;
        background-color: #f6f6f6;
        color:  #999;
        text-align: right;
        padding-right: 10px;
        border-top: solid 1px #3A9DCB;       
    }
    .copyright {
    	font-family: Arial;
    	font-size: 12px;
    	text-align: right;
    	padding-top: 7px;
    }
    .footerD 
    {
        max-width: 768px;
        color:  #3a9dcb;
        text-align: left;
        padding-right: 10px;
        border-top: solid 1px #3A9DCB;
        font-style: italic;       
    }
    .disclaimer {
    	font-family: Arial;
    	font-size: 12px;
    	padding-top: 60px;
    }
    .placeholder {
        height: 7px;
        width:  768px; 
        background-color: #FFF;    
    }
    /* Header */
     .logoutBtn {
        float: right;  
        margin-right: -155px;
        font-size: smaller;
        padding-top: 4px;
        text-align: right;
    }
    .loginName {
        float: right;  
        margin-right: -100px;
        font-size:smaller;
        padding-top: 4px; 
    }
    .logAs {
        float: right;
        margin-right: -5px;
        font-size:smaller;
        color: #3A9DCB;
        padding-top: 4px;
    }
    .traineeName {
        float: left;
        padding-left: 10px;   
        font-family: Arial;
        font-weight: bold;   
        color: #000066; 
        padding-top: 4px;
    }
    .traineeJob {
        float: left;
        padding-left: 25px;
        font-family: Arial;
        padding-top: 4px;       
    }
    .yearOfStudy {
        float: left;
        padding-left: 25px;   
        font-family: Arial;  
        padding-top: 4px; 
    }
    .monthOfStudy {
        float: left;
        padding-left: 25px;
        font-family: Arial;   
        padding-top: 4px;
    }
    .name_line {
        height: 23px;
        width:  768px;
        border-top: dashed 1px #3A9DCB;
        border-bottom: dashed 1px #3A9DCB;
        background-color: #f6f6f6;
    }
    .main_content
    {
        height: 382px;
        width:  758px;
        background-color: #FFFFFF;
    	padding: 5px;      
    }
    /* PAGE IN QUESTION */
    .tblReportSelection {
    	float: left;
    	border: solid 1px #373188;
    	padding: 5px;
    	padding-right: 20px;
    	text-align: left;
    }
    .alignLeft 
    {
    	text-align: left;
    	float:left;
    }
    /* I THINK THE PROB LIES HERE! */
    .tblReportSelection a {
    	color: #000000;
    	text-decoration: none;
    	font-size: 12px;
    }
    .tblReportSelection a:link {
    	color: #000000;
    	text-decoration: none;
    	font-size: 12px;
    }
    .tblReportSelection a:active {
    	color: #000000;
    	text-decoration: none;
    	font-size: 12px;
    }
    .tblSubmitSelection {
    	float: left;
    	overflow: auto;
    }

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Layout turns funny after MessageBox appears!

    OK, suggestion.
    Why not make use of the document.write method ( of JavaScript ) to write the term : "No Records Found" onto the body of the website - then, you don't need the Alert box at all ¿

  5. #5
    Join Date
    Jan 2010
    Posts
    130

    Unhappy Re: Layout turns funny after MessageBox appears!

    Thanks, I tried that but it doesnt work for two reasons:
    1) The text is not in a dialogbox in the center of the screen
    2) The layout still repositions itself

    I would be grateful if someone could tell me how to stop the layout changing after the dialogbox has been clicked!

  6. #6
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Layout turns funny after MessageBox appears!

    Where do you call your alert call? Is it client- or serverside?

    I had some similar problem in the past, and that was because I did the next on server side
    Code:
    Response.Write("alert('Hello');");

  7. #7
    Join Date
    Jan 2010
    Posts
    130

    Re: Layout turns funny after MessageBox appears!

    How do I know if Im doing it client or server side? This is what my alert call looks like:

    Code:
            protected void MessageBox(string message)
            {
                if (!string.IsNullOrEmpty(message))
                {
                    Response.Write("<script type=\"text/javascript\" language=\"javascript\">");
                    Response.Write("alert('" + message + "');");
                    Response.Write("</script>");
                }
            }
    And this is how I call it:

    Code:
     protected void GetActiveTrainees()
            {
                try
                {
                    // Get an array of the active trainees
                    traineesActive = SData.mWebService.getAllTraineeActive();
    
                    if (traineesActive.Length > 0)
                    {
                        CreateTblTrainee();
                    }
                    else
                    {
                        MessageBox("Es würde kein Auszubildender in der Datenbank gefunden.");
                    }
                }
                catch (Exception e)
                {
                     SData.tCurrentError = e.GetType();
                     Response.Redirect("Error.aspx", true);
                }
            }

  8. #8
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Layout turns funny after MessageBox appears!

    If you take a look at the HTML output, the script probably will be above the <html> tag

    You need to use
    Code:
    Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "my_script", "alert('hello');", true);
    PS. I don't have Visual Studio right now, so there could be a small syntax error

  9. #9
    Join Date
    Jan 2010
    Posts
    130

    Re: Layout turns funny after MessageBox appears!

    Perfect!!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured