Can ASP NET do this?

Pyrite1

New Member
I have a delete button that calls a function that deletes a record in a database. My question is does ASP Net have an easy way to make a ok cancel box pop up with a message like "Are you sure you want to delete this record?". Has anyone seen some code like this? If so if you could point it out to me thanks.an easy way? no. Because the code is ran on the server the traditional MsgBox wont work because the box would try to appear on the server. <BR>I can think of a few ways you can go about this, but here a a few links that might help you with your problem.<BR><BR>http://www.asp.net/ControlGallery/default.aspx?Category=7&tabindex=2<BR><BR>http://www.codecube.net/item.asp?cc_ItemID=87Yes, this can easily be solved using .NET. However, you can do this even easier by just putting a "onSubmit" javascript function that pops up the message in your form. It's a 1 line solution, takes all of about 30 seconds, and works perfectly. You can do a search for "javascript confirm" and probably find about 1000000 sites to tell you how to do it..//---------------------------------------------------------------------------------------------<BR> function ConfirmFaqDelete(IntFaqId) {<BR> //---------------------------------------------------------------------------------------------<BR> //this function will ask a user if they really want to sign out<BR> var Msg = 'Are you sure that you want to delete FAQ ' + IntFaqId + '?';<BR> if (confirm(Msg)) {<BR> location.replace('<%=StrThisPage%>?Action=Delete&Id=' + IntFaqId);<BR> }<BR> }<BR><BR><BR>then like someone suggested, just throw an onSubmit in the button.Whats the difference between the javascript Broy wrote and the javascript in the user control here?<BR>http://www.codecube.net/item.asp?cc_ItemID=87I use confirm buttons quite often and personally it would be way to tedious for me to continually enter this same code in over and over again. <BR><BR>Why wouldnt you just install a control to make it much easier and faster? After all, you did say you wanted it to be easy, didnt you?<BR><BR>If you want to do it the reusable, ASP .Net way, wrap it into a user control. Then you don't have to rewrite each time you want to use it, and you can even add it to your toolbox.The difference is, I posted a short note to hopefully help him find exactly what he was trying to accomplish in the least amount of time. Your links were there as well, I said that it could be accomplished with ASP.NET. But there is no faster way that typing onSubmit='javascript:confirm("Are you sure that you want to do this?")' in the form. What's the big deal about people suggesting multiple ways to do things?I agree with Jay - the user control may take that little bit longer to st up (about 30 seconds probably!!) but it is then reusable and is also much more in line with the concepts and recommended guidelines of .Net development.<BR>For a strictly one off though, I'd probably take the Javascript route as suggested above.
 
Back
Top