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. How to avoid postback of ASP: Image Button

How to avoid postback of ASP: Image Button

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavascripttutorialquestion
6 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.
  • C Offline
    C Offline
    ChandrakanthGaddam
    wrote on last edited by
    #1

    Hi, This is from Chandrakanth. i have one problem with update panel in Ajax in aspx page div tag is there. In that some controls are there. i kept that div tag in the Update Panel to avoid post back by Asp:Image button click event. I am using Asp:ImageButton. When i click on that image button client side code that is Javascript code should work as well as c# code should works. problem is when i click on that Asp:ImageButton, post back is happening for DIV Tag. I want to avoid that post back of DIV tag. How can i avoid that. Please help me out from this problem. Thanks and Regards Chandrakanth

    S M 2 Replies Last reply
    0
    • C ChandrakanthGaddam

      Hi, This is from Chandrakanth. i have one problem with update panel in Ajax in aspx page div tag is there. In that some controls are there. i kept that div tag in the Update Panel to avoid post back by Asp:Image button click event. I am using Asp:ImageButton. When i click on that image button client side code that is Javascript code should work as well as c# code should works. problem is when i click on that Asp:ImageButton, post back is happening for DIV Tag. I want to avoid that post back of DIV tag. How can i avoid that. Please help me out from this problem. Thanks and Regards Chandrakanth

      S Offline
      S Offline
      saini arun
      wrote on last edited by
      #2

      OnClientClick='javascript: SwitchMenus(); return false;'

      C 1 Reply Last reply
      0
      • S saini arun

        OnClientClick='javascript: SwitchMenus(); return false;'

        C Offline
        C Offline
        ChandrakanthGaddam
        wrote on last edited by
        #3

        Hi, Once again from Chandrakanth. if i use that code , Only Javascript code is working.But C# code is not working which was mention on onclick event. any suggestions for this. Thanks and Regards Chandrakanth

        1 Reply Last reply
        0
        • C ChandrakanthGaddam

          Hi, This is from Chandrakanth. i have one problem with update panel in Ajax in aspx page div tag is there. In that some controls are there. i kept that div tag in the Update Panel to avoid post back by Asp:Image button click event. I am using Asp:ImageButton. When i click on that image button client side code that is Javascript code should work as well as c# code should works. problem is when i click on that Asp:ImageButton, post back is happening for DIV Tag. I want to avoid that post back of DIV tag. How can i avoid that. Please help me out from this problem. Thanks and Regards Chandrakanth

          M Offline
          M Offline
          michaelschmitt
          wrote on last edited by
          #4

          I'm understanding that you have an imagebutton and a div with some other controls within an updatepanel. When you click your imagebutton, you want client and server-side code to run but not update the contents of your updatepanel? First, set the updatemode of your updatepanel to "conditional". then, either place the imagebutton outside that panel (maybe into another updatepanel) or add this to your update-panel-markup: ChildrenAsTriggers="false" This prevents the updatepanel from updating its content if the imagebutton is clicked. If you set ChildrenAsTriggers="false" , you can still add specific triggers to the triggers-section of the updatepanel-markup. Use UpdatePanelName.Update() to update the contents from server-side. Good Luck

          C 1 Reply Last reply
          0
          • M michaelschmitt

            I'm understanding that you have an imagebutton and a div with some other controls within an updatepanel. When you click your imagebutton, you want client and server-side code to run but not update the contents of your updatepanel? First, set the updatemode of your updatepanel to "conditional". then, either place the imagebutton outside that panel (maybe into another updatepanel) or add this to your update-panel-markup: ChildrenAsTriggers="false" This prevents the updatepanel from updating its content if the imagebutton is clicked. If you set ChildrenAsTriggers="false" , you can still add specific triggers to the triggers-section of the updatepanel-markup. Use UpdatePanelName.Update() to update the contents from server-side. Good Luck

            C Offline
            C Offline
            ChandrakanthGaddam
            wrote on last edited by
            #5

            Hi, Once again from Chandrakanth. Thanks for prompt reply. Problem is when i click on Image button, CLIENT SIDE CODE is executing, next POST BACK is happening, C# CODE is executing. Actually my problem is i want to avoid that POST BACK when i click on ASP:IMAGE BUTTON. Any suggestion please............ Thanks and Regards Chandrakanth

            M 1 Reply Last reply
            0
            • C ChandrakanthGaddam

              Hi, Once again from Chandrakanth. Thanks for prompt reply. Problem is when i click on Image button, CLIENT SIDE CODE is executing, next POST BACK is happening, C# CODE is executing. Actually my problem is i want to avoid that POST BACK when i click on ASP:IMAGE BUTTON. Any suggestion please............ Thanks and Regards Chandrakanth

              M Offline
              M Offline
              michaelschmitt
              wrote on last edited by
              #6

              To Prevent the postback, you can return false in your clientscript - but this prevents the server-side-code from running. You cannot simply avoid that postback. This means, you cannot simply use the clientside AND SERVER-SIDE on-click events without a postback. You can limit the effects this postback has by using updatepanels and (if!ispostback..) code-blocks in your server-side code. You can also figure out, which control raised the postback. BUT - Maybe this is a solution to your problem? - Hope this helps

              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