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. calling codebehind method from javascript

calling codebehind method from javascript

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthelp
4 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.
  • V Offline
    V Offline
    Vinay Dornala
    wrote on last edited by
    #1

    Hi genious, i had a scenario like this , i have 2 pages, from page 1 i am opening page 2 with window.open in page 2 having yes button and 4 check boxes, iam getting this checkbox details when iam clicking yes with window.opener to page1. when iam comming back to page 1 i need to execute code behind method based on checkboxes values. i problem is how do call code behind method when iam on page1 with javascript or .net thanks in Advance,

    M 1 Reply Last reply
    0
    • V Vinay Dornala

      Hi genious, i had a scenario like this , i have 2 pages, from page 1 i am opening page 2 with window.open in page 2 having yes button and 4 check boxes, iam getting this checkbox details when iam clicking yes with window.opener to page1. when iam comming back to page 1 i need to execute code behind method based on checkboxes values. i problem is how do call code behind method when iam on page1 with javascript or .net thanks in Advance,

      M Offline
      M Offline
      Mircea Grelus
      wrote on last edited by
      #2

      You could set the values of the checkboxes in a hidden filed in the parent window using window.parent. Then, assuming you have a button on page 1 you call window.parent.__doPostBack('ButtonName','') from page 2, and on the serverside in the click event of that button get the values of the hidden field using Request.Form('hiddenName')

      Cheers, Mircea "Pay people peanuts and you get monkeys" - David Ogilvy

      V 1 Reply Last reply
      0
      • M Mircea Grelus

        You could set the values of the checkboxes in a hidden filed in the parent window using window.parent. Then, assuming you have a button on page 1 you call window.parent.__doPostBack('ButtonName','') from page 2, and on the serverside in the click event of that button get the values of the hidden field using Request.Form('hiddenName')

        Cheers, Mircea "Pay people peanuts and you get monkeys" - David Ogilvy

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        Mircea Grelus wrote:

        get the values of the hidden field using Request.Form('hiddenName')

        Everything looks OK Mircea, except this. ASP.NET has ServerSide HiddenField which can be accessed like hiddenName.Value in the CodeBehind.

        Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

        M 1 Reply Last reply
        0
        • V Venkatesh Mookkan

          Mircea Grelus wrote:

          get the values of the hidden field using Request.Form('hiddenName')

          Everything looks OK Mircea, except this. ASP.NET has ServerSide HiddenField which can be accessed like hiddenName.Value in the CodeBehind.

          Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

          M Offline
          M Offline
          Mircea Grelus
          wrote on last edited by
          #4

          Yes you're right. If you add the runat="server" property to the input field, it will make it a server control and you will be able to access it using it's name.

          Cheers, Mircea "Pay people peanuts and you get monkeys" - David Ogilvy

          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