Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Alert Function In asp.net

Alert Function In asp.net

Scheduled Pinned Locked Moved ASP.NET
questioncsharpjavascriptasp-net
15 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    V 2
    wrote on last edited by
    #1

    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...

    R J 2 Replies Last reply
    0
    • V V 2

      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...

      R Offline
      R Offline
      rajanandal
      wrote on last edited by
      #2

      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... :)

      V 1 Reply Last reply
      0
      • R rajanandal

        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... :)

        V Offline
        V Offline
        V 2
        wrote on last edited by
        #3

        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

        R C 2 Replies Last reply
        0
        • V V 2

          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

          R Offline
          R Offline
          rajanandal
          wrote on last edited by
          #4

          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... :)

          V 1 Reply Last reply
          0
          • V V 2

            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

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            ~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 )

            V 1 Reply Last reply
            0
            • R rajanandal

              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... :)

              V Offline
              V Offline
              V 2
              wrote on last edited by
              #6

              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...

              1 Reply Last reply
              0
              • C Christian Graus

                ~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 )

                V Offline
                V Offline
                V 2
                wrote on last edited by
                #7

                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

                C 1 Reply Last reply
                0
                • V V 2

                  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

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  ~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 1 Reply Last reply
                  0
                  • C Christian Graus

                    ~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 Offline
                    V Offline
                    V 2
                    wrote on last edited by
                    #9

                    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.........

                    C J 2 Replies Last reply
                    0
                    • V V 2

                      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.........

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      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

                      J 1 Reply Last reply
                      0
                      • C Christian Graus

                        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

                        J Offline
                        J Offline
                        J4amieC
                        wrote on last edited by
                        #11

                        Almost as good as "How to Use Google". * golfclap *

                        C 1 Reply Last reply
                        0
                        • V V 2

                          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...

                          J Offline
                          J Offline
                          J4amieC
                          wrote on last edited by
                          #12

                          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 use FindControl 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.

                          1 Reply Last reply
                          0
                          • V V 2

                            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.........

                            J Offline
                            J Offline
                            Jeremy Falcon
                            wrote on last edited by
                            #13

                            ~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[^]

                            1 Reply Last reply
                            0
                            • J J4amieC

                              Almost as good as "How to Use Google". * golfclap *

                              C Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #14

                              *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 )

                              V 1 Reply Last reply
                              0
                              • C Christian Graus

                                *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 )

                                V Offline
                                V Offline
                                V 2
                                wrote on last edited by
                                #15

                                "The great pleasure in doing that things that other people say U can't "

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups