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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Java script function in aspx.vb file [modified]

Java script function in aspx.vb file [modified]

Scheduled Pinned Locked Moved ASP.NET
javavisual-studiotools
28 Posts 7 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.
  • G Girish481

    Hello, I am using VS 2005 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If Trim(TextBox1.Text) = "" Or Val(TextBox1.Text) > Val(TextBox2.Text) Or Trim(TextBox2.Text) = "" Or Val(TextBox2.Text) < Val(TextBox1.Text) Then <modified on Friday, June 19, 2009 12:30 AM

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    Sorry friend i know this for C# so that i m telling u.. button.Attributes.Add( "onClick", "return compareStartAndEndTime();"); Inside ur condition try below code its working for me...... try it out string script = "<script language='javascript'>"; script += "alert('Patient Id Can not be left blank');\n"; script += "</script>"; RegisterStartupScript("StartUp", script);

    modified on Friday, June 19, 2009 2:02 AM

    G 1 Reply Last reply
    0
    • L Lost User

      Sorry friend i know this for C# so that i m telling u.. button.Attributes.Add( "onClick", "return compareStartAndEndTime();"); Inside ur condition try below code its working for me...... try it out string script = "<script language='javascript'>"; script += "alert('Patient Id Can not be left blank');\n"; script += "</script>"; RegisterStartupScript("StartUp", script);

      modified on Friday, June 19, 2009 2:02 AM

      G Offline
      G Offline
      Girish481
      wrote on last edited by
      #5

      Thanks for your reply; but it will only fire onclick function; it will not execute the next part of the code which has been written in the Sub..End Sub.

      C 1 Reply Last reply
      0
      • K K0306

        try this In .aspx file write script <script type="text/javascript"> function AlertMessage() { alert("hi"); } </script> and in .vb file call script function Page.ClientScript.RegisterStartupScript(GetType(ScriptMode), "", "AlertMessage()", True)

        G Offline
        G Offline
        Girish481
        wrote on last edited by
        #6

        There is blue underline with "ScriptMode" saying "Type 'ScriptMode' is not defined.

        1 Reply Last reply
        0
        • G Girish481

          Thanks for your reply; but it will only fire onclick function; it will not execute the next part of the code which has been written in the Sub..End Sub.

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

          Your core issue is that you are clueless. No, you cannot make a page cycle pause half way through to run some JS, then continue. Not possible. Anyone who thinks it might be, has no idea about ASP.NET. You can do a postback, or you can use AJAX. You need a seperate call between the code that runs before the alert, and the code that runs after.

          Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

          G 1 Reply Last reply
          0
          • G Girish481

            Hello, I am using VS 2005 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If Trim(TextBox1.Text) = "" Or Val(TextBox1.Text) > Val(TextBox2.Text) Or Trim(TextBox2.Text) = "" Or Val(TextBox2.Text) < Val(TextBox1.Text) Then <modified on Friday, June 19, 2009 12:30 AM

            B Offline
            B Offline
            Baran M
            wrote on last edited by
            #8

            for your case, try this Response.Write("<script language='javascript'>alert('Hello');</script>");

            Education is not a way to escape poverty — it is a way of fighting it.

            G 1 Reply Last reply
            0
            • B Baran M

              for your case, try this Response.Write("<script language='javascript'>alert('Hello');</script>");

              Education is not a way to escape poverty — it is a way of fighting it.

              G Offline
              G Offline
              Girish481
              wrote on last edited by
              #9

              Thanks for your working reply; the only thing came new in the picture that now if the alert comes on the page; and i click on ok button of the alert; the font style of all the textboxes becomess bold; and if i click on back button of the browser; it always send me the alert message.

              B 1 Reply Last reply
              0
              • G Girish481

                Thanks for your working reply; the only thing came new in the picture that now if the alert comes on the page; and i click on ok button of the alert; the font style of all the textboxes becomess bold; and if i click on back button of the browser; it always send me the alert message.

                B Offline
                B Offline
                Baran M
                wrote on last edited by
                #10

                post your code plz

                Education is not a way to escape poverty — it is a way of fighting it.

                G 1 Reply Last reply
                0
                • G Girish481

                  Hello, I am using VS 2005 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If Trim(TextBox1.Text) = "" Or Val(TextBox1.Text) > Val(TextBox2.Text) Or Trim(TextBox2.Text) = "" Or Val(TextBox2.Text) < Val(TextBox1.Text) Then <modified on Friday, June 19, 2009 12:30 AM

                  K Offline
                  K Offline
                  koolprasad2003
                  wrote on last edited by
                  #11

                  just try to use Response.write("alert('YOUE Message')") hope it helps regards koolprasad2003 :)

                  If the message is useful for U then please Rate This message... Be a good listener...Because Opprtunity knoughts softly...N-Joy

                  1 Reply Last reply
                  0
                  • C Christian Graus

                    Your core issue is that you are clueless. No, you cannot make a page cycle pause half way through to run some JS, then continue. Not possible. Anyone who thinks it might be, has no idea about ASP.NET. You can do a postback, or you can use AJAX. You need a seperate call between the code that runs before the alert, and the code that runs after.

                    Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                    G Offline
                    G Offline
                    Girish481
                    wrote on last edited by
                    #12

                    I am cluless, do'nt know asp.net programming; but what will you do; if such case/issue come to you where you have to code/solve the problem; how can i send the alert message to the user.

                    C 1 Reply Last reply
                    0
                    • B Baran M

                      post your code plz

                      Education is not a way to escape poverty — it is a way of fighting it.

                      G Offline
                      G Offline
                      Girish481
                      wrote on last edited by
                      #13

                      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If Trim(TextBox1.Text) = "" Or Val(TextBox1.Text) > Val(TextBox2.Text) Or Trim(TextBox2.Text) = "" Or Val(TextBox2.Text) < Val(TextBox1.Text) Then Response.Write("<script language='javascript'>alert('Wrong Roll Number Ranges');</script>") Exit Sub End If setreport() Dim ss As String ss = tablename & ".aspx?startrol=" & TextBox1.Text & "&endrol=" & TextBox2.Text If Response.IsClientConnected Then Server.Transfer(ss) End If End Sub

                      H 1 Reply Last reply
                      0
                      • G Girish481

                        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If Trim(TextBox1.Text) = "" Or Val(TextBox1.Text) > Val(TextBox2.Text) Or Trim(TextBox2.Text) = "" Or Val(TextBox2.Text) < Val(TextBox1.Text) Then Response.Write("<script language='javascript'>alert('Wrong Roll Number Ranges');</script>") Exit Sub End If setreport() Dim ss As String ss = tablename & ".aspx?startrol=" & TextBox1.Text & "&endrol=" & TextBox2.Text If Response.IsClientConnected Then Server.Transfer(ss) End If End Sub

                        H Offline
                        H Offline
                        himanshu2561
                        wrote on last edited by
                        #14

                        Hi, Try this

                        ScriptManager.RegisterStartupScript(Me, GetType(String), "OPEN_WINDOW", "alert('hi');", True)

                        himanshu

                        G B 2 Replies Last reply
                        0
                        • H himanshu2561

                          Hi, Try this

                          ScriptManager.RegisterStartupScript(Me, GetType(String), "OPEN_WINDOW", "alert('hi');", True)

                          himanshu

                          G Offline
                          G Offline
                          Girish481
                          wrote on last edited by
                          #15

                          There is blue underline with ScriptManager saying "Name 'ScriptManager' is not declared" Which namespace i have to add?

                          H 1 Reply Last reply
                          0
                          • G Girish481

                            I am cluless, do'nt know asp.net programming; but what will you do; if such case/issue come to you where you have to code/solve the problem; how can i send the alert message to the user.

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

                            If you're doing homework, you should talk to your teacher. If you're teaching yourself, start with something more basic. If you are doing paid work, then you are a disgrace, you should tell your client that you're robbing them. If someone hired you, they are a disgrace, also. I told you want to do. You need to change your overall design, because you cannot prompt the user in the middle of a postback. If you're not asking them a question, if you just show a message, you can probably show it in the middle of what you're doing. If you're redirecting to a new page, that page needs to show the message.

                            Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                            G 1 Reply Last reply
                            0
                            • G Girish481

                              There is blue underline with ScriptManager saying "Name 'ScriptManager' is not declared" Which namespace i have to add?

                              H Offline
                              H Offline
                              himanshu2561
                              wrote on last edited by
                              #17

                              System.Web.UI

                              himanshu

                              G 1 Reply Last reply
                              0
                              • H himanshu2561

                                System.Web.UI

                                himanshu

                                G Offline
                                G Offline
                                Girish481
                                wrote on last edited by
                                #18

                                Still same error please.

                                H 1 Reply Last reply
                                0
                                • C Christian Graus

                                  If you're doing homework, you should talk to your teacher. If you're teaching yourself, start with something more basic. If you are doing paid work, then you are a disgrace, you should tell your client that you're robbing them. If someone hired you, they are a disgrace, also. I told you want to do. You need to change your overall design, because you cannot prompt the user in the middle of a postback. If you're not asking them a question, if you just show a message, you can probably show it in the middle of what you're doing. If you're redirecting to a new page, that page needs to show the message.

                                  Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

                                  G Offline
                                  G Offline
                                  Girish481
                                  wrote on last edited by
                                  #19

                                  I am disgrace, i am robbing my client. Thanks for putting "personal attack" replies in the general forum by such an expert person. Its really shocking how easy they write; who gave them such rights, rather than helping the students/novice developers. I have'nt read anywhere till now, that ignorance is a crime or helping the people means you have full right to "show" the bossism.

                                  C 1 Reply Last reply
                                  0
                                  • H himanshu2561

                                    Hi, Try this

                                    ScriptManager.RegisterStartupScript(Me, GetType(String), "OPEN_WINDOW", "alert('hi');", True)

                                    himanshu

                                    B Offline
                                    B Offline
                                    Baran M
                                    wrote on last edited by
                                    #20

                                    Is it not for only AJAX ? is it available for .net 2.0

                                    Education is not a way to escape poverty — it is a way of fighting it.

                                    1 Reply Last reply
                                    0
                                    • G Girish481

                                      Still same error please.

                                      H Offline
                                      H Offline
                                      himanshu2561
                                      wrote on last edited by
                                      #21

                                      Are you using framework 2.0?

                                      himanshu

                                      G 1 Reply Last reply
                                      0
                                      • H himanshu2561

                                        Are you using framework 2.0?

                                        himanshu

                                        G Offline
                                        G Offline
                                        Girish481
                                        wrote on last edited by
                                        #22

                                        Yes please. I have seen in control panel-add remove programme and there is Microsoft.NET Framework 2.0

                                        H 1 Reply Last reply
                                        0
                                        • G Girish481

                                          Yes please. I have seen in control panel-add remove programme and there is Microsoft.NET Framework 2.0

                                          H Offline
                                          H Offline
                                          himanshu2561
                                          wrote on last edited by
                                          #23

                                          Well you are using .net framework 2.0 So,you have to add reference of "AJAXCONTROLTOOLKIT"

                                          himanshu

                                          G 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