ASP prompt issue

Peter_1985 2,526 Reputation points
2021-08-11T04:07:29.3+00:00

Hi,
In ASP, is there one example to show message prompt below?
122136-prompt-message.png

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,187 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,270 questions
{count} votes

10 answers

Sort by: Most helpful
  1. AgaveJoe 26,136 Reputation points
    2021-08-17T18:38:14.07+00:00

    Below is a minimal example in ASP.NET Web Forms.

            <script>
                function ShowMessage(message) {
                    $('#exampleModal div.modal-body').text(message);
                    $('#exampleModal').modal('show')
                }
            </script>
    

    Code behind

    namespace WebFormsDemo.Bootstrap
    {
        public partial class Alert : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowMessage('Message to display');", true);
            }
        }
    }
    

    Bootstrap modal

    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
            <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
            </div>
            <div class="modal-body">
    
            </div>
            <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
            </div>
        </div>
        </div>
    </div>
    

    Keep in mind, your original screenshot loads two different versions of jQuery and jQueryUI and Bootstrap are competing frameworks. Use one or the other not both. The example above uses jQuery 3 and Bootstrap 3

    <script src="../Scripts/jquery-3.6.0.js"></script>
    <script src="../Scripts/bootstrap.min.js"></script>
    
    0 comments No comments

  2. Peter_1985 2,526 Reputation points
    2021-08-18T04:50:45.783+00:00

    Hi,
    Thanks to all.

    Yijing,
    I run the browser "as administrator" but same issue below

    Access Denied
    You don't have permission to access "http://learn.microsoft.com/answers/answers/509073/post.html" on this server.
    Reference #18.6edb0d17.1629262159.2e929e7e

    AgaveJoe,
    Where do you call "Button1_Click"?


  3. Peter_1985 2,526 Reputation points
    2021-08-19T03:28:55.887+00:00

    Hi all,
    With codes below
    124495-1b.png
    124496-1c.png

            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowMessage('Message to display Aug19');", true);    
    

    I have prompt like
    124494-1d.png

    it is not in the original format (I originally posted to this)


  4. Peter_1985 2,526 Reputation points
    2021-08-19T09:15:17.497+00:00

    Hi,
    I do not have source. Is the one (in green) below one picture file? How to have the similar effect (per given sample with screenshot) to the prompt?
    124588-1g.png


  5. Peter_1985 2,526 Reputation points
    2021-08-20T01:50:00.33+00:00

    Hi,
    I'm using VS 2015. How to ensure aria-labelledby is recognizable?

    0 comments No comments