Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:58:09+00:00 2026-06-15T10:58:09+00:00

I am using alert message using java-script to display some kind of warning when

  • 0

I am using alert message using java-script to display some kind of warning when some conditions are not met. My only problem is when the alert message pops up and the users reads the message and clicks Ok, then it goes back to the original page but the page shifts to the left side. Normally my page shows in the center but only when the java-script runs then it shifts to the left side of the page. If i copy the same URL and paste in another page then everything will be aligned and will show in the center. How can i fix this? is there another alerting message like jquery or something else that works nice. Pls. help. thnaks

  using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using AjaxControlToolkit;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web.Routing;

public partial class HomePage : System.Web.UI.Page
{


    protected void Page_Load(object sender, EventArgs e)
    {
        string ID = Page.RouteData.Values["ID"] as string;

        if (!IsPostBack)
        {

            BindData_Action();

        }       
    }


protected void btnApproval_Click(object sender, EventArgs e)
    {

        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString);
        SqlDataAdapter da = new SqlDataAdapter("SELECT ID, Description, Target_Date FROM MyTable  WHERE ID = '" + Request.QueryString["ID"] + "'", con);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {

         //if the condition above is true i am sending an email

        }
        else
        {
            Response.Write("<script>alert('Before requesting Approval additional info.  Thanks');</script>");
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:58:11+00:00Added an answer on June 15, 2026 at 10:58 am

    Using Response.Write can do some funky things to your styling. Instead of doing it in your C# code, break out the javascript separately.

    One way to do it is to use RegisterStartUpScript in your C# – this tells the compiler to run this script after the page is loaded:

    If (!Page.ClientScript.IsStartupScriptRegistered("showAlert") {
        Page.ClientScript.RegisterStartupScript(Page.GetType(), "showAlert", "showAlert();", True);
    }
    

    And then, right after your C# code section on your page ends, add this:

    <script type="text/javascript">
        function showAlert() {
            alert('Before requesting Approval, you MUST add at least one Action Item.  Thanks');
        }
    </script>
    

    All this is doing is separating out the javascript that you had in your Response.Write.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application where I am showing an alert message using UIAlertView. By
I am using Bootstrap alerts and this is my success alert message: <div class=alert
For some strange reason, an alert dialog with the text title Message From Web
I am using simple JavaScript code in my PHP code to display an alert
I'm trying to dynamically create alert messages using the jQuery plugin for Bootstrap CSS.
I'm using jGrowl to display messages and alerts, the datepicker I'm using is triggering
How do I debug a Node.js server application? Right now I'm mostly using alert
I want to trigger javascript alert using PHP. Is it possible I want to
We alert user using this javascript, now i want to add this functionality to
I have created an alert view with two buttons using the following code: UIAlertView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.