Alert Function In asp.net
-
Hi all I m using Asp.net(Vb) and When the user wants to delete the item i'll have to show a Message Box with Ok and Cancel. In Vb.net we can use Msgbox() but in asp.net it gives error so i'll have to use javascript' alert function() for it but how can i use it in my code file abc.vb not in the abc.aspx(source file). And if i use it in source file then how can i access the result(ok or canel) in my code file' button click event???
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim result As MsgBoxResult result = MsgBox("Do you want to delete the record permanantely?", MsgBoxStyle.OkCancel) If result = MsgBoxResult.Ok Then Sql = "Delete from items where userid=" & Session("userid") & " and itemid=" + itemid.ToString cmd = New SqlCommand(Sql, cnn) cmd.CommandType = CommandType.Text Me.cnn.Open() Me.cmd.ExecuteNonQuery() Me.cnn.Close() Me.add_record() End If End Sub
Thanks with anticipation... -
Hi all I m using Asp.net(Vb) and When the user wants to delete the item i'll have to show a Message Box with Ok and Cancel. In Vb.net we can use Msgbox() but in asp.net it gives error so i'll have to use javascript' alert function() for it but how can i use it in my code file abc.vb not in the abc.aspx(source file). And if i use it in source file then how can i access the result(ok or canel) in my code file' button click event???
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim result As MsgBoxResult result = MsgBox("Do you want to delete the record permanantely?", MsgBoxStyle.OkCancel) If result = MsgBoxResult.Ok Then Sql = "Delete from items where userid=" & Session("userid") & " and itemid=" + itemid.ToString cmd = New SqlCommand(Sql, cnn) cmd.CommandType = CommandType.Text Me.cnn.Open() Me.cmd.ExecuteNonQuery() Me.cnn.Close() Me.add_record() End If End Sub
Thanks with anticipation...In ASP.Net u can use Javascript confirm for this purpose. based on return value of confirm u can delete the record.
Nothing is Impossible. Keep always Smiling... :)
-
In ASP.Net u can use Javascript confirm for this purpose. based on return value of confirm u can delete the record.
Nothing is Impossible. Keep always Smiling... :)
Thanks for your response but sir as i mentioned earlier i know that i can use javascript's alert function but how can i use it in my code file private sub button1_click(BYVAL sender as object,byval e as eventargs) result=alert("Do you want to delete the record permanantely?") and if i use it in source file than how can i access the result( ok or cancel) result = alert("Do you want to delete the record permanantely?") from my code file????? I hope u'll understand my problem Looking forward 4 your response
-
Thanks for your response but sir as i mentioned earlier i know that i can use javascript's alert function but how can i use it in my code file private sub button1_click(BYVAL sender as object,byval e as eventargs) result=alert("Do you want to delete the record permanantely?") and if i use it in source file than how can i access the result( ok or cancel) result = alert("Do you want to delete the record permanantely?") from my code file????? I hope u'll understand my problem Looking forward 4 your response
u use VB as a code behind language. in Inline code U can use Javascript. for ex. Inline code ---------- script> function check() { if(confirm("Do u want to delete")) return true; else return false; } /script> asp:button text="delete" id="b1" onclick="b1_click" onclientclick="return check()" /
Nothing is Impossible. Keep always Smiling... :)
-
Thanks for your response but sir as i mentioned earlier i know that i can use javascript's alert function but how can i use it in my code file private sub button1_click(BYVAL sender as object,byval e as eventargs) result=alert("Do you want to delete the record permanantely?") and if i use it in source file than how can i access the result( ok or cancel) result = alert("Do you want to delete the record permanantely?") from my code file????? I hope u'll understand my problem Looking forward 4 your response
~V~ wrote:
result=alert("Do you want to delete the record permanantely?")
No, that just plain does not work. Buy a book on ASP.NET and read it, please. It looks to me like what you want to do, is that have the button that does the deleting, call some script on the cleint to prompt the user, and only do the postback ( and therefore the delete ), if they click yes.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
u use VB as a code behind language. in Inline code U can use Javascript. for ex. Inline code ---------- script> function check() { if(confirm("Do u want to delete")) return true; else return false; } /script> asp:button text="delete" id="b1" onclick="b1_click" onclientclick="return check()" /
Nothing is Impossible. Keep always Smiling... :)
Your help was great but Can i ask more boz actully i m using grid view and in my grid view there is a column Delete so when the user clicks on delete i'll have to ask that wether he is sure or not and how can i add these line for grid view
asp:button text="delete" id="b1" onclick="b1_click" onclientclick="return check()" /
Thanks for your idea... -
~V~ wrote:
result=alert("Do you want to delete the record permanantely?")
No, that just plain does not work. Buy a book on ASP.NET and read it, please. It looks to me like what you want to do, is that have the button that does the deleting, call some script on the cleint to prompt the user, and only do the postback ( and therefore the delete ), if they click yes.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
result=alert("Do you want to delete the record permanantely?")
I wrote this just to specify what i wanna do its not the correct syntax i know sir and i m newbie in asp.net~V~ wrote:
i m newbie in asp.net
Then why are you writing code that will delete someones database records ? Tell me this is homework and not paid work ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
~V~ wrote:
i m newbie in asp.net
Then why are you writing code that will delete someones database records ? Tell me this is homework and not paid work ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
For your kind information its not my home work its my project and i m not a student, i m a software engineer and have experience of more than 1 year in vb.net and now i wanna work in asp.net that's why is said that i m newbiew to asp.net. I respect all the senior person in codeproject boz of their helping nature and once you also helped me to solve my problem and i m still greatful for that but that doesn't means u can say anything to me. Its not the right way to talk someone being a senior person Any ways let it go.........
-
For your kind information its not my home work its my project and i m not a student, i m a software engineer and have experience of more than 1 year in vb.net and now i wanna work in asp.net that's why is said that i m newbiew to asp.net. I respect all the senior person in codeproject boz of their helping nature and once you also helped me to solve my problem and i m still greatful for that but that doesn't means u can say anything to me. Its not the right way to talk someone being a senior person Any ways let it go.........
I'm sorry to say that you've proven my point. You've used VB.NET for one year ? A computer science course takes 3-4 years, and you list no other languages, how much of the one year of your life that you've known how to write a bit of code, were you paid for it ? You're obvioulsy learning ASP.NET by taking paid projects in it, that is just plain disgusting, but not surprising, given the bad experiences I've had with Indian outsourcing companies. As far as I can see, a lot of outsourcing firms hire people who have no idea, and then expect the people in the West who are losing their jobs as a result, to do their work, on the basis of their inability and unwillingness to buy books, use google, and spend some time learning before they expect to be paid for their efforts. I am always happy to help people, that's why I am here. But, the direction our industry is taking is upsetting to me. I take solace in the fact that outsourcing companies are still offering poor quality of code and inexperienced workers, I feel sure I'm not going to see my job threatened, but I feel equally sure that in the eyes of those stupid enough to use outsourcing companies, what I do is being devalued. You refer to me as a senior person. I can tell you for sure, that if I interviewed someone for an ASP.NET position, and they didn't know the things you obviously didn't know from your first post, I would not even consider them. I would probably tell war stories about the person who needed to be in college, not trying to be paid for their efforts. But, you are not alone. The double tragedy is that people where I live can't find good developers, I know of many companies that cannot find a skilled dev because people have left computer science, wrongly thinking there would be no work. I have recently been paid $80 an hour by a company that can't find skilled worker locally, and have tried to outsource briefly and found just what a nightmare it is for all but the most menial tasks. That's $166,000 a year, less than I earn, but 3 times what the average developer used to make around here. So, please don't tell me what the right way is to talk. I've helped you, and I've also tried to make you realise just how far you have to go before you can hold your head up high when asking to be paid for writing ASP.NET code. My desire in doing this is to inspire you to actually rise above the standards of those around you, and do some study, to become an actual software engineer, able to do research, able to understand the frameworks you are
-
I'm sorry to say that you've proven my point. You've used VB.NET for one year ? A computer science course takes 3-4 years, and you list no other languages, how much of the one year of your life that you've known how to write a bit of code, were you paid for it ? You're obvioulsy learning ASP.NET by taking paid projects in it, that is just plain disgusting, but not surprising, given the bad experiences I've had with Indian outsourcing companies. As far as I can see, a lot of outsourcing firms hire people who have no idea, and then expect the people in the West who are losing their jobs as a result, to do their work, on the basis of their inability and unwillingness to buy books, use google, and spend some time learning before they expect to be paid for their efforts. I am always happy to help people, that's why I am here. But, the direction our industry is taking is upsetting to me. I take solace in the fact that outsourcing companies are still offering poor quality of code and inexperienced workers, I feel sure I'm not going to see my job threatened, but I feel equally sure that in the eyes of those stupid enough to use outsourcing companies, what I do is being devalued. You refer to me as a senior person. I can tell you for sure, that if I interviewed someone for an ASP.NET position, and they didn't know the things you obviously didn't know from your first post, I would not even consider them. I would probably tell war stories about the person who needed to be in college, not trying to be paid for their efforts. But, you are not alone. The double tragedy is that people where I live can't find good developers, I know of many companies that cannot find a skilled dev because people have left computer science, wrongly thinking there would be no work. I have recently been paid $80 an hour by a company that can't find skilled worker locally, and have tried to outsource briefly and found just what a nightmare it is for all but the most menial tasks. That's $166,000 a year, less than I earn, but 3 times what the average developer used to make around here. So, please don't tell me what the right way is to talk. I've helped you, and I've also tried to make you realise just how far you have to go before you can hold your head up high when asking to be paid for writing ASP.NET code. My desire in doing this is to inspire you to actually rise above the standards of those around you, and do some study, to become an actual software engineer, able to do research, able to understand the frameworks you are
-
Hi all I m using Asp.net(Vb) and When the user wants to delete the item i'll have to show a Message Box with Ok and Cancel. In Vb.net we can use Msgbox() but in asp.net it gives error so i'll have to use javascript' alert function() for it but how can i use it in my code file abc.vb not in the abc.aspx(source file). And if i use it in source file then how can i access the result(ok or canel) in my code file' button click event???
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim result As MsgBoxResult result = MsgBox("Do you want to delete the record permanantely?", MsgBoxStyle.OkCancel) If result = MsgBoxResult.Ok Then Sql = "Delete from items where userid=" & Session("userid") & " and itemid=" + itemid.ToString cmd = New SqlCommand(Sql, cnn) cmd.CommandType = CommandType.Text Me.cnn.Open() Me.cmd.ExecuteNonQuery() Me.cnn.Close() Me.add_record() End If End Sub
Thanks with anticipation...Lets try this one more time. After reading this response go back and look over the responses you've already been given. The way to achieve what you want in ASP is to attach a client side confirm box which stops postback if the user clicks "Cancel". To stop a postback from a link, or button, you return false in the OnClientClick. handiliy, the javascript
confirm
returns false if the user click "Cancel". Hence:OnClientClick="return confirm('Are you sure you wish to delete this item')"
Finally, if you need to do this within a grid with a delete button/link the idea is to useFindControl
to get a reference to the link/button and append the relevant OnClientClick. If any of this is hard for you to understand I have given you a plethora of keywords to search google for. -
For your kind information its not my home work its my project and i m not a student, i m a software engineer and have experience of more than 1 year in vb.net and now i wanna work in asp.net that's why is said that i m newbiew to asp.net. I respect all the senior person in codeproject boz of their helping nature and once you also helped me to solve my problem and i m still greatful for that but that doesn't means u can say anything to me. Its not the right way to talk someone being a senior person Any ways let it go.........
~V~ wrote:
software engineer
Everyone is an engineer nowadays, that title means at lot less than it used to. Hell, even garbage men are called Sanitation Engineers in the PC world.
Jeremy Falcon Oatmeal Engine[^]
-
*blush* Normally I try to keep it in, but this guy just pushed the wrong buttons on the wrong day.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
*blush* Normally I try to keep it in, but this guy just pushed the wrong buttons on the wrong day.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )