Last post Mar 26, 2013 08:40 AM by Rion Williams
Mar 26, 2013 08:13 AM|ssvikramuk|LINK
Hi - how to stop a script in webmatrix,
ModelState.AddError("email", "Category already exists");
@Html.Raw("<script>alert('Email Address Already Exiists');</script>") <!-----Stop script should be here---> }
Mar 26, 2013 08:23 AM|Rion Williams|LINK
What do you mean by "stopping the script"?
Otherwise, your closing <script> tag will essentially mark the end of your actual <script> block.
Mar 26, 2013 08:36 AM|ssvikramuk|LINK
in php we can call like Exit to stop the whole scripti like that we have any in webmatrix?
Mar 26, 2013 08:40 AM|Rion Williams|LINK
this discussion suggests throwing an exception like so :
<!-- Return Examples -->
@Html.Raw("<script>return alert('Email Address Already Exists');</script>")
@Html.Raw("<script>alert('Email Address Already Exists'); return;</script>")
<!-- Exception Examples -->
@Html.Raw("<script>alert('Email Address Already Exists'); throw 'stop execution';</script>")
However, you should be fine using your current code as it is just a simple alert and will basically be disregarded once you close it.