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. Using Javascript and server side code to handle button click event

Using Javascript and server side code to handle button click event

Scheduled Pinned Locked Moved ASP.NET
csharpquestionjavascriptasp-netsysadmin
3 Posts 3 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.
  • A Offline
    A Offline
    Adam Brown 3
    wrote on last edited by
    #1

    I am using ASP.Net with C#, framework 3.5. I am working on a page that uses a "Next" button on a master page to inititate a server side click event to do some processing using a session object, and then a Server.Transfer to the next page. The same Master page "Next" button handles all the pages in the app. At some point I am sure that I will need to inroduce a client side click event to do client side validation on one of the pages. What is the best way to do the client side validation and still utilize the server side click event code I already wrote? Or should I abandon my server side click event code and just do everything on the client side?

    B R 2 Replies Last reply
    0
    • A Adam Brown 3

      I am using ASP.Net with C#, framework 3.5. I am working on a page that uses a "Next" button on a master page to inititate a server side click event to do some processing using a session object, and then a Server.Transfer to the next page. The same Master page "Next" button handles all the pages in the app. At some point I am sure that I will need to inroduce a client side click event to do client side validation on one of the pages. What is the best way to do the client side validation and still utilize the server side click event code I already wrote? Or should I abandon my server side click event code and just do everything on the client side?

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      Better if you use ASP.NET validators.Have different validation for different page and have a javascript function,pass it with and the validation group and validate the it using page_clientvalidate('groupname') and return false if it fails then your server side event would not fire else return true.It'll continue to postback. For more info about asp.net validators have a look to one of my article Exploring ASP.NET Validators

      Cheers!! Brij Check my latest Article :URL Routing with ASP.NET 4.0

      1 Reply Last reply
      0
      • A Adam Brown 3

        I am using ASP.Net with C#, framework 3.5. I am working on a page that uses a "Next" button on a master page to inititate a server side click event to do some processing using a session object, and then a Server.Transfer to the next page. The same Master page "Next" button handles all the pages in the app. At some point I am sure that I will need to inroduce a client side click event to do client side validation on one of the pages. What is the best way to do the client side validation and still utilize the server side click event code I already wrote? Or should I abandon my server side click event code and just do everything on the client side?

        R Offline
        R Offline
        Ryan McBeth
        wrote on last edited by
        #3

        I agree with Brji... But there may be another way. I try to stay away from client side JavaScript. It's too hard to debug and test. But you could always have the "Next" button postback and make a decision to continue (Response.Redirect(whatever.aspx) or to not continue based on the entered information. I do it quite frequently, but I come from a WinForms background where I'm used to having fine control over the actions of the user. I think anytime you rely on JavaScript, you will get burned in the long run with compatibility issues anyway. Ryan

        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