Customize IE and Chrome Dialog Box

Qamar, Mo 106 Reputation points
2022-04-01T16:11:31.963+00:00

How do I customize IE and Chrome Dialog Box that says:

localhost:83 says

189283-ajax.txt

Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. AgaveJoe 30,126 Reputation points
    2022-04-01T19:57:14.643+00:00

    It's not possible to customize the alert. A modal as a good alternative but you'll need to make a few changes in the markup. Basically, the modal is part of the page markup. You'll show/hide the modal and maybe dynamically populate the contents.

    Just do a Google search for a modal that fits into your current design.


  2. Albert Kallal 5,586 Reputation points
    2022-04-01T20:17:09.193+00:00

    Well, those built in dialog boxes (for reasons of security) tend to spit out your web url. Now, of course when you publish to a real production site - with a domain name, then that local host text will show as your URL.

    However, at the end of the day? They look quite bad - and don't allow you any customizing.

    So, I suggest you find and adopt a nice "dialog" box. There are boatloads of them on the internet, but the real problem is which one to pick and use?

    I tend to think going with say the most popular one, and also the one that is the "least" efforts on your part.

    For asp.net web pages? I suggest two possibilities that are really nice.

    If you already using the AjaxToolkit, then it has a very nice pop dialog add-in, and I used that one in the past quite a bit.

    Next choice? a lot suggest bootstrap ones, but I find them really difficult to work with, but that's a possible.

    And my current favorite choice? Well, 99% of web sites - even for about 10 years now for asp.net web forms? You have and will use jQuery. It is installed by default, so I suggest you add in jQuery.UI. It has a bunch of great options like sliding panels and "accordions", and has a REALLY nice dialog box.

    Edit:

    Here is a example of how one looks:

    Say we have this grid view with a delete button

    189288-image.png

    So, our delete button in the grid view is this:

    189289-image.png

    So, if we click on that button, then the confirm dialog pops up - the default built in one. As above shows - not very pretty at all.

    And the code behind for that delete button is quite simple:

        Protected Sub cmdDelete_Click(sender As Object, e As EventArgs)  
      
            Dim btn As LinkButton = sender  
            Dim gRow As GridViewRow = btn.NamingContainer  
            Dim PKID As Integer = GridView1.DataKeys(gRow.RowIndex).Item("ID")  
      
            Dim strSQL As String = "DELETE FROM tblHotels WHERE ID = " & PKID  
      
            Using conn As New SqlConnection(My.Settings.TEST4)  
                Using cmdSql As New SqlCommand(strSQL, conn)  
                    conn.Open()  
                    cmdSql.ExecuteNonQuery()  
                End Using  
            End Using  
      
            LoadGrid()  
      
        End Sub  
    

    Now, lets do the same with jQuery.UI dialog.

    The button code becomes this:

    189361-image.png

    Once again, like all asp.net buttons - if the onclientclick returns true, then the button runs, else if we return false, the button does not fire (run server side code behind).

    So, with jQuery.UI, we use a div for the popup, and have this div and code now:

    189297-image.png

    Now, when I hit delete button, the dialog is custom - and very nice:

    189298-image.png

    And it even "darkens" the rest of the screen. So, consider grabbing a dialog utility. There are number, but the above is a jQuery.ui example to give you an idea of what they look like.

    Regards,
    Albert D. Kallal (Access MVP 2003-2017)
    Edmonton, Alberta Canada


  3. Yijing Sun-MSFT 7,096 Reputation points
    2022-04-04T05:26:59.967+00:00

    Hi @Qamar, Mo ,
    I think you could use Ajax ModalPopupExtender. It could popup the windows without the 'localhost'.

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.