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. jquery for asp.net sometimes work sometimes doesn't work

jquery for asp.net sometimes work sometimes doesn't work

Scheduled Pinned Locked Moved ASP.NET
javascripthelpcsharpasp-nettools
4 Posts 2 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.
  • D Offline
    D Offline
    Dhyanga
    wrote on last edited by
    #1

    Hi, I have jquery implemented for the popup confirmation on radio button select. So my radio button has yes or no options. so in each select, the popup should show up and based on the option, it has to hide and show the panel. But the problem is sometimes for the same option, jquery runs and sometimes for the same option jsquery doesn't run. the following jquery is in my aspx page.

    <script language="JavaScript" type="text/javascript">

        $(document).ready(function() {
    
    
    
    function confirmDelete()
         {
             if (confirm('It will delete your file. Is that Ok?'))
            {
                document.getElementById('<%= radbutSelector.ClientID %>').click();
                return true;
            }
            return false;
        }
    
    </script>
    

    Now i have called this jquery on radio button select like this

    And the code behind the radio button select is like this

    protected void radbutSelector_Click(object sender, EventArgs e)
    {

                if (radWantEnter.SelectedValue == "Yes")
                {
                    pnl1.Visible = true;
                   
                }
    
                else
                {
                    pnl2.Visible = false;
                    
                }
           
        }
    

    sometimes the radbutSelector executes its codes and sometimes its not for the same event. Any idea and any solutions would be great help.

    Dhyanga

    J 1 Reply Last reply
    0
    • D Dhyanga

      Hi, I have jquery implemented for the popup confirmation on radio button select. So my radio button has yes or no options. so in each select, the popup should show up and based on the option, it has to hide and show the panel. But the problem is sometimes for the same option, jquery runs and sometimes for the same option jsquery doesn't run. the following jquery is in my aspx page.

      <script language="JavaScript" type="text/javascript">

          $(document).ready(function() {
      
      
      
      function confirmDelete()
           {
               if (confirm('It will delete your file. Is that Ok?'))
              {
                  document.getElementById('<%= radbutSelector.ClientID %>').click();
                  return true;
              }
              return false;
          }
      
      </script>
      

      Now i have called this jquery on radio button select like this

      And the code behind the radio button select is like this

      protected void radbutSelector_Click(object sender, EventArgs e)
      {

                  if (radWantEnter.SelectedValue == "Yes")
                  {
                      pnl1.Visible = true;
                     
                  }
      
                  else
                  {
                      pnl2.Visible = false;
                      
                  }
             
          }
      

      sometimes the radbutSelector executes its codes and sometimes its not for the same event. Any idea and any solutions would be great help.

      Dhyanga

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      That's a csharp code behind function, there is no Jquery on any example except for $(document).ready. and that's not correct either. You don't need document ready unless your binding events with the document ready. I can't see how confirm delete works, where does the object confirm come from?

      <script language="JavaScript" type="text/javascript">

      $(document).ready(function() {

      });

      function confirmDelete()
           {
               if (confirm('It will delete your file. Is that Ok?'))
              {
                  document.getElementById('<%= radbutSelector.ClientID %>').click();
                  return true;
              }
              return false;
          }
       
      
      </script>
      
      D 1 Reply Last reply
      0
      • J jkirkerx

        That's a csharp code behind function, there is no Jquery on any example except for $(document).ready. and that's not correct either. You don't need document ready unless your binding events with the document ready. I can't see how confirm delete works, where does the object confirm come from?

        <script language="JavaScript" type="text/javascript">

        $(document).ready(function() {

        });

        function confirmDelete()
             {
                 if (confirm('It will delete your file. Is that Ok?'))
                {
                    document.getElementById('<%= radbutSelector.ClientID %>').click();
                    return true;
                }
                return false;
            }
         
        
        </script>
        
        D Offline
        D Offline
        Dhyanga
        wrote on last edited by
        #3

        The script is like this:

        <script language="JavaScript" type="text/javascript">

        function confirmDelete()
             {
                 if (confirm('It will delete your file. Is that Ok?'))
                {
                    document.getElementById('<%= radbutSelector.ClientID %>').click();
                    return true;
                }
                return false;
            }
         
        
        </script>
        

        Dhyanga

        J 1 Reply Last reply
        0
        • D Dhyanga

          The script is like this:

          <script language="JavaScript" type="text/javascript">

          function confirmDelete()
               {
                   if (confirm('It will delete your file. Is that Ok?'))
                  {
                      document.getElementById('<%= radbutSelector.ClientID %>').click();
                      return true;
                  }
                  return false;
              }
           
          
          </script>
          

          Dhyanga

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          In Jquery, it's more along the lines of this. I guessed at the ID or the radio button set, won't work, just an example of how to format it. but it's closer to what you want. So it binds the change event to the DOM, and fires the function, passing the event to it. Radio buttons are checkboxs, they act the same, and have the same events, so think of them as checkboxes. If you have a group of them, say 2, then you have to get the selected index of the 2 radio buttons, which is an array of values, from the DOM. That's what the [0] is for. I was about to leave tor the night and sleep, but wanted to help a little more if possible. I can tell your not that familiar with Jquery. If you have an update panel on the page, this won't work after using the update panel once, because the DOM unloaded.

          <script language="JavaScript" type="text/javascript">

          $(document).ready( function() {
          
               $('\[id\*="radbutSelector"\]').change( function(event) {
                  confirmDelete(event);
               });
          });   
          
          function confirmDelete(event) {
              var newradio= $("input\[name='pick\_up\_point'\]:checked")\[0\];
          
              if (newradio===currentradio)
                  return;
              if (confirm('Address details will be cleared. Continue?')) {
                  clearInputFields();
                  currentradio= newradio;
              } else {
                  currentradio.checked= true;
              }
          }   
          
          </script>
          
          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