How to avoid postback of ASP: Image Button
-
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
-
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
OnClientClick='javascript: SwitchMenus(); return false;'
-
OnClientClick='javascript: SwitchMenus(); return false;'
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
-
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
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
-
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
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
-
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
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