1

In my asp.net website,i want to show a notification to the user when he/she try to delete data , i have used a msgbox in my vb code but it didn't work on the server side , i have searched and found that i should use java script alert ,i have used it but the problem is that it appears at the top of the screen and its so simple how can i make an alert or dialog like the following image using java script and vb

enter image description here

this is my code

 Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click

   ScriptManager.RegisterStartupScript(Page, Page.GetType,Guid.NewGuid().ToString(), "alert('you cannot delete this data ')", True)

  End Sub

Please any one can help me , any help would be appreciated

Thanks in advance

user
  • 621
  • 15
  • 46
  • Possible duplicate of [How to show/display message box in C# asp.net forms?](http://stackoverflow.com/questions/21655132/how-to-show-display-message-box-in-c-sharp-asp-net-forms) – mortb Dec 30 '15 at 09:10

1 Answers1

1

The problem is that a dialog box is not built into asp.net. You need to either just use the javascript alert / confirm functions, create the dialogbox yourself using html or import a GUI-library such as JQuery UI.

Here is a guide on how to use JQuery UI dialog, which I have used many times in ASP.NET: https://cmatskas.com/how-to-use-jquery-dialog-as-confirm-dialog-in-asp-net/

mortb
  • 9,361
  • 3
  • 26
  • 44
  • Thanks for your help , can we improve the design of the java script alert and make it more customized without using jQuery ? you have any idea how the alert design using this jQuery would be ? is it like the one in the image that i have posted ? since I want to make a styled alert – user Dec 30 '15 at 09:37
  • No, you cannot do any changes to the javascript alert; the behavior is "hard wired". If you want to create the dialog your self using html, css and javascript you usually create your own html `div` or `span` that you may show or hide and functions like a dialog. To explore the options please look at the answers here: http://stackoverflow.com/questions/21655132/how-to-show-display-message-box-in-c-sharp-asp-net-forms About Jquery dialog:look at the jquery dialog page https://jqueryui.com/dialog/ for examples and customization options. (Sorry for not getting back earlier, I've had vacation.) – mortb Jan 07 '16 at 13:46