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. General Programming
  3. C#
  4. How to write Events in Asp .Net

How to write Events in Asp .Net

Scheduled Pinned Locked Moved C#
csharpasp-netwinformstutorial
6 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.
  • M Offline
    M Offline
    Member 8480980
    wrote on last edited by
    #1

    how to write events in asp.net like in windows forms leave events,key press event.

    E A B 3 Replies Last reply
    0
    • M Member 8480980

      how to write events in asp.net like in windows forms leave events,key press event.

      E Offline
      E Offline
      Ed Hill _5_
      wrote on last edited by
      #2

      After a little look on google there are lots of solutions out there, a good search including what you need to do when the leave or keypress event would give you an answer. You may be best posting in the ASP.NET forum. You could get started here.

      1 Reply Last reply
      0
      • M Member 8480980

        how to write events in asp.net like in windows forms leave events,key press event.

        A Offline
        A Offline
        Alagiri periyasamy merrillcorp com
        wrote on last edited by
        #3

        Keypress event is used when you want to write the code based on the keys having ASCII value. The second argument e for keypress event is of type keypresseventargs and it has a property keychar that contains the character pressed by the user on the keyboard and this property is used to write the codein keypress event. can you try this for keypress event: private void KeypressEvent_KeyPress(object sender, KeyPressEventArgs e) { switch (e.KeyChar) { case 'A': case 'a': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) + Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'S': case 's': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) - Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'M': case 'm': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) * Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'D': case 'd': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) / Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'C': case 'c': TxtNum1.Clear(); TxtNum2.Clear(); TxtResult.Clear(); TxtNum1.Focus(); e.Handled = true; break; case 'X': case 'x': this.Close(); break; } }

        L 1 Reply Last reply
        0
        • A Alagiri periyasamy merrillcorp com

          Keypress event is used when you want to write the code based on the keys having ASCII value. The second argument e for keypress event is of type keypresseventargs and it has a property keychar that contains the character pressed by the user on the keyboard and this property is used to write the codein keypress event. can you try this for keypress event: private void KeypressEvent_KeyPress(object sender, KeyPressEventArgs e) { switch (e.KeyChar) { case 'A': case 'a': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) + Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'S': case 's': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) - Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'M': case 'm': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) * Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'D': case 'd': TxtResult.Text = (Convert.ToInt32(TxtNum1.Text) / Convert.ToInt32(TxtNum2.Text)).ToString(); e.Handled = true; break; case 'C': case 'c': TxtNum1.Clear(); TxtNum2.Clear(); TxtResult.Clear(); TxtNum1.Focus(); e.Handled = true; break; case 'X': case 'x': this.Close(); break; } }

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

          Read the question carefully before attempting to answer.

          1 Reply Last reply
          0
          • M Member 8480980

            how to write events in asp.net like in windows forms leave events,key press event.

            B Offline
            B Offline
            BobJanova
            wrote on last edited by
            #5

            For most events you want to add JavaScript client side event handlers. You can write server side event handlers on anything with runat=server but these cause the page to be posted back and reloaded, which is annoying to work with.

            M 1 Reply Last reply
            0
            • B BobJanova

              For most events you want to add JavaScript client side event handlers. You can write server side event handlers on anything with runat=server but these cause the page to be posted back and reloaded, which is annoying to work with.

              M Offline
              M Offline
              Member 8480980
              wrote on last edited by
              #6

              Thank u BobJanova.,

              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