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

textbox event

Scheduled Pinned Locked Moved ASP.NET
23 Posts 6 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.
  • M mylogics

    hii... i hav 3 textbox named:txtqty,txtproductprice,txttotalprice. i want that when the cursor goes to txttotalprice.the txttotalprice textbox get initialized by the value which is multiple of txtqty and txtproductprice.i hav used the textbox changed event of txttotalprice like this: then i hav coded it like this: protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); } but it doesnt show any value in txttotalprice...

    P Offline
    P Offline
    padmanabhan N
    wrote on last edited by
    #2

    mylogics wrote:

    protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); }

    --instead use { double i = double.parse(txtqty.Text); double j = double.parse(txtproductprice.Text); double l = i*j; txttotalprice.Text = l.Tostring(); }

    Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

    C M 2 Replies Last reply
    0
    • M mylogics

      hii... i hav 3 textbox named:txtqty,txtproductprice,txttotalprice. i want that when the cursor goes to txttotalprice.the txttotalprice textbox get initialized by the value which is multiple of txtqty and txtproductprice.i hav used the textbox changed event of txttotalprice like this: then i hav coded it like this: protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); } but it doesnt show any value in txttotalprice...

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

      This sort of thing gets posted EVERY day. Imagine if your page actually refreshed EVERY time you typed something ? This event fires if you force a postback by other means. To do what you want, it needs to be done in javascript,

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      1 Reply Last reply
      0
      • M mylogics

        hii... i hav 3 textbox named:txtqty,txtproductprice,txttotalprice. i want that when the cursor goes to txttotalprice.the txttotalprice textbox get initialized by the value which is multiple of txtqty and txtproductprice.i hav used the textbox changed event of txttotalprice like this: then i hav coded it like this: protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); } but it doesnt show any value in txttotalprice...

        B Offline
        B Offline
        Blue_Boy
        wrote on last edited by
        #4

        Why you don't use javscript for that calculation?


        I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

        M 1 Reply Last reply
        0
        • P padmanabhan N

          mylogics wrote:

          protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); }

          --instead use { double i = double.parse(txtqty.Text); double j = double.parse(txtproductprice.Text); double l = i*j; txttotalprice.Text = l.Tostring(); }

          Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

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

          If you have no idea what the answer is, it's best to stay silent. Your code is not functionally different from his, and both suffer from the same basic problem.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          1 Reply Last reply
          0
          • P padmanabhan N

            mylogics wrote:

            protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); }

            --instead use { double i = double.parse(txtqty.Text); double j = double.parse(txtproductprice.Text); double l = i*j; txttotalprice.Text = l.Tostring(); }

            Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

            M Offline
            M Offline
            mylogics
            wrote on last edited by
            #6

            hiii still not workin.it just shows nothin in txttotalprice.

            1 Reply Last reply
            0
            • B Blue_Boy

              Why you don't use javscript for that calculation?


              I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

              M Offline
              M Offline
              mylogics
              wrote on last edited by
              #7

              can u give me some idea hw cud i use javascript for this calculation...

              B 1 Reply Last reply
              0
              • M mylogics

                can u give me some idea hw cud i use javascript for this calculation...

                B Offline
                B Offline
                Blue_Boy
                wrote on last edited by
                #8

                Here it is. function Calculate() { document.getElementById('<%=txttotalprice.ClientID%>').value= document.getElementById('<%=txtqty.ClientID%>').value * document.getElementById('<%=txtproductprice.ClientID%>').value }


                I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post. www.aktualiteti.com

                1 Reply Last reply
                0
                • M mylogics

                  hii... i hav 3 textbox named:txtqty,txtproductprice,txttotalprice. i want that when the cursor goes to txttotalprice.the txttotalprice textbox get initialized by the value which is multiple of txtqty and txtproductprice.i hav used the textbox changed event of txttotalprice like this: then i hav coded it like this: protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); } but it doesnt show any value in txttotalprice...

                  S Offline
                  S Offline
                  sajjy
                  wrote on last edited by
                  #9

                  hi you know , i think you`d better not do that like this !!! :-D because ontextchanged , sends the information to the server andyour page relodes and takes so much time ! it`s better to do this on client side with java script something like this :

                  var quantity = document.getElementById('txtqty').value;
                  var price = document.getElementById('txtproductprice').value;
                  document.getElementById('txttotalprice').value = quantity*price;

                  :cool:

                  M 1 Reply Last reply
                  0
                  • S sajjy

                    hi you know , i think you`d better not do that like this !!! :-D because ontextchanged , sends the information to the server andyour page relodes and takes so much time ! it`s better to do this on client side with java script something like this :

                    var quantity = document.getElementById('txtqty').value;
                    var price = document.getElementById('txtproductprice').value;
                    document.getElementById('txttotalprice').value = quantity*price;

                    :cool:

                    M Offline
                    M Offline
                    mylogics
                    wrote on last edited by
                    #10

                    is there any other way to do this without using javascript bcoz i dont know javascript n how to implement it... :(

                    S P 2 Replies Last reply
                    0
                    • M mylogics

                      is there any other way to do this without using javascript bcoz i dont know javascript n how to implement it... :(

                      S Offline
                      S Offline
                      sajjy
                      wrote on last edited by
                      #11

                      javascript is the best way ;) if you have a masterpage , the way that blue boy said is better than mine :) code it like this in your .aspx page :

                      the code that blue boy said

                      S 1 Reply Last reply
                      0
                      • S sajjy

                        javascript is the best way ;) if you have a masterpage , the way that blue boy said is better than mine :) code it like this in your .aspx page :

                        the code that blue boy said

                        S Offline
                        S Offline
                        sajjy
                        wrote on last edited by
                        #12

                        oh i forgot to say something else ;) in your code that you made textboxes you must add this function like this :

                        M 1 Reply Last reply
                        0
                        • M mylogics

                          is there any other way to do this without using javascript bcoz i dont know javascript n how to implement it... :(

                          P Offline
                          P Offline
                          padmanabhan N
                          wrote on last edited by
                          #13

                          //as sajjy says function total() { var quantity = document.getElementById('txtqty').value; var price = document.getElementById('txtproductprice').value; document.getElementById('txttotalprice').value = quantity*price; } //call that event in the textbox onblur():

                          Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

                          M 1 Reply Last reply
                          0
                          • M mylogics

                            hii... i hav 3 textbox named:txtqty,txtproductprice,txttotalprice. i want that when the cursor goes to txttotalprice.the txttotalprice textbox get initialized by the value which is multiple of txtqty and txtproductprice.i hav used the textbox changed event of txttotalprice like this: then i hav coded it like this: protected void txttotalprice_TextChanged(object sender, EventArgs e) { string s = txtqty.Text; string k = txtproductprice.Text; int i = Convert.ToInt32(s); int j = Convert.ToInt32(k); int l = i * j; txttotalprice.Text = Convert.ToString(i); } but it doesnt show any value in txttotalprice...

                            S Offline
                            S Offline
                            Sundeep Ganiga
                            wrote on last edited by
                            #14

                            Dear Guys, You People have left one thing,onblur event(given by padmanabhan) should be written to Two text boxes(txtqty and txtproductprice).In Function we have to Check whether these two TextBoxes are not null and if it is not so , Then multiply and display data in third textbox. Writing an event for third textbox is of no use here. Sundeep Ganiga

                            When the only tool you have is a hammer, everything looks like a nail. Come Forth Yourself to Click "Good Answer" for any expected solution. Let us Support our C Project Programmers who provide solutions here.

                            S 1 Reply Last reply
                            0
                            • S sajjy

                              oh i forgot to say something else ;) in your code that you made textboxes you must add this function like this :

                              M Offline
                              M Offline
                              mylogics
                              wrote on last edited by
                              #15

                              its not workin... function Calculate() { document.getElementById('<%=txttotalprice.ClientID%>').value= document.getElementById('<%=txtqty.ClientID%>').value * document.getElementById('<%=txtproductprice.ClientID%>').value } wat to do...

                              S 1 Reply Last reply
                              0
                              • P padmanabhan N

                                //as sajjy says function total() { var quantity = document.getElementById('txtqty').value; var price = document.getElementById('txtproductprice').value; document.getElementById('txttotalprice').value = quantity*price; } //call that event in the textbox onblur():

                                Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

                                M Offline
                                M Offline
                                mylogics
                                wrote on last edited by
                                #16

                                hiii onblur event does not exist... oninit(),onload(),onunlload,ontextchanged(),onprerender()...exist which event shud i use....

                                1 Reply Last reply
                                0
                                • M mylogics

                                  its not workin... function Calculate() { document.getElementById('<%=txttotalprice.ClientID%>').value= document.getElementById('<%=txtqty.ClientID%>').value * document.getElementById('<%=txtproductprice.ClientID%>').value } wat to do...

                                  S Offline
                                  S Offline
                                  sajjy
                                  wrote on last edited by
                                  #17

                                  change it to this one :

                                  function Calculate()
                                  {
                                  document.getElementById('<%=txttotalprice.ClientID%>').value=
                                  document.getElementById('<%=txtqty.ClientID%>').value *
                                  document.getElementById('<%=txtproductprice.ClientID%>').value

                                  }

                                  notice that javascript is Case Sencetive ! :-\

                                  M 1 Reply Last reply
                                  0
                                  • S sajjy

                                    change it to this one :

                                    function Calculate()
                                    {
                                    document.getElementById('<%=txttotalprice.ClientID%>').value=
                                    document.getElementById('<%=txtqty.ClientID%>').value *
                                    document.getElementById('<%=txtproductprice.ClientID%>').value

                                    }

                                    notice that javascript is Case Sencetive ! :-\

                                    M Offline
                                    M Offline
                                    mylogics
                                    wrote on last edited by
                                    #18

                                    hiii.... sir there is no onfocus event.... the events are.. oninit(),onload(),onunload(),onprerender(),ontextchanged()... which event shud i use...

                                    S 1 Reply Last reply
                                    0
                                    • S Sundeep Ganiga

                                      Dear Guys, You People have left one thing,onblur event(given by padmanabhan) should be written to Two text boxes(txtqty and txtproductprice).In Function we have to Check whether these two TextBoxes are not null and if it is not so , Then multiply and display data in third textbox. Writing an event for third textbox is of no use here. Sundeep Ganiga

                                      When the only tool you have is a hammer, everything looks like a nail. Come Forth Yourself to Click "Good Answer" for any expected solution. Let us Support our C Project Programmers who provide solutions here.

                                      S Offline
                                      S Offline
                                      sajjy
                                      wrote on last edited by
                                      #19

                                      yes you are right !!! :laugh: but first we can let him to create his first javascript , then he can do any thing he wants ;)

                                      M 1 Reply Last reply
                                      0
                                      • M mylogics

                                        hiii.... sir there is no onfocus event.... the events are.. oninit(),onload(),onunload(),onprerender(),ontextchanged()... which event shud i use...

                                        S Offline
                                        S Offline
                                        sajjy
                                        wrote on last edited by
                                        #20

                                        hehehe i know :-D visual studio is stupid ;) javascript runs at client computers , so don`t worry :) just use it :cool:

                                        M 1 Reply Last reply
                                        0
                                        • S sajjy

                                          hehehe i know :-D visual studio is stupid ;) javascript runs at client computers , so don`t worry :) just use it :cool:

                                          M Offline
                                          M Offline
                                          mylogics
                                          wrote on last edited by
                                          #21

                                          hiii great finally it worked... thanks alot... thank you very much sir specially sajjy,padmanabhan and blue boy... Best Regards pari....

                                          B 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