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. ASP.Net MVC and querySelectorAll usage

ASP.Net MVC and querySelectorAll usage

Scheduled Pinned Locked Moved ASP.NET
asp-netcsharpjavascripthtmlarchitecture
3 Posts 2 Posters 3 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
    Mou_kol
    wrote on last edited by
    #1

    Please see the code.

    using (Html.BeginForm("Login", "Default", new { ReturnUrl = ViewBag.ReturnUrl, data = Request.QueryString["data"] }, FormMethod.Post,
    new
    {
    id = "idtest1",
    onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)",
    @class = "form-signin",
    role = "form"
    }))
    {

    }

    specially see this line which is not clear to me. onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)", in the above code BeginForm html helper has been used to render form at runtime. what will happen when form will be submitted ? what this line will do when form submit ? onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)", please help me to understand this JavaScript code objective when form submit. Thanks

    Richard DeemingR 1 Reply Last reply
    0
    • M Mou_kol

      Please see the code.

      using (Html.BeginForm("Login", "Default", new { ReturnUrl = ViewBag.ReturnUrl, data = Request.QueryString["data"] }, FormMethod.Post,
      new
      {
      id = "idtest1",
      onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)",
      @class = "form-signin",
      role = "form"
      }))
      {

      }

      specially see this line which is not clear to me. onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)", in the above code BeginForm html helper has been used to render form at runtime. what will happen when form will be submitted ? what this line will do when form submit ? onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)", please help me to understand this JavaScript code objective when form submit. Thanks

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      That line sets the onsubmit attribute on the <form> element to the specified Javascript string. It's an old way of attaching an event handler to an element. When the form is submitted, all buttons on that form will have their disabled property set to false. But that won't actually accomplish anything; a button's name and value are only submitted with the form if you click on that button, and you can't click on a disabled button.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      M 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        That line sets the onsubmit attribute on the <form> element to the specified Javascript string. It's an old way of attaching an event handler to an element. When the form is submitted, all buttons on that form will have their disabled property set to false. But that won't actually accomplish anything; a button's name and value are only submitted with the form if you click on that button, and you can't click on a disabled button.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        M Offline
        M Offline
        Mou_kol
        wrote on last edited by
        #3

        Sir, thank you so much for reply.

        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