解决方法
基本上,这取决于您如何将值插入数据库,因为您需要一种方法来告诉您插入是否成功.因为现在有几种方法可以做到,linq / entity framework / sql / etc.
然后在您知道插入是否发生之后,您可以只为变量赋值,然后从代码/ aspx中检查值并执行简单警报.
<script type="text/javascript"> //i'm using jquery ready event which will call the javascript chunk after the page has completed loading $(document).ready(function(){ //assuming that your variable name from the code behind is bInsertSuccess var bSuccess = "<%= bInsertSuccess %>"; if(bSuccess){ alert("Successfully Inserted"); } }); </script>