Posts Tagged ‘postback’

Updatepanel triggers another updatepanel

August 18, 2017 Leave a comment


By default, every UpdatePanel will be refreshed during every asynchronous post back.

Some important remarks about Update Panel

When an UpdatePanel control is not inside another UpdatePanel control, the panel is updated according to the settings of the UpdateMode and ChildrenAsTriggers properties, together with the collection of triggers. When an UpdatePanel control is inside another UpdatePanel control, the child panel is automatically updated when the parent panel is updated.

The content of an UpdatePanel control is updated in the following circumstances:

  • If the UpdateMode property is set to Always, the UpdatePanel control’s content is updated on every postback that originates from anywhere on the page. This includes asynchronous postbacks from controls that are inside other UpdatePanel controls and postbacks from controls that are not inside UpdatePanel controls.
  • If the UpdatePanel control is nested inside another UpdatePanel control and the parent update panel is updated.
  • If the UpdateMode property is set to Conditional, and one of the following conditions occurs:
    • You call the Update method of the UpdatePanel control explicitly.
    • The postback is caused by a control that is defined as a trigger by using the Triggers property of the UpdatePanel control. In this scenario, the control explicitly triggers an update of the panel content. The control can be either inside or outside the UpdatePanelcontrol that defines the trigger.
    • The ChildrenAsTriggers property is set to true and a child control of the UpdatePanel control causes a postback. A child control of a nested UpdatePanel control does not cause an update to the outer UpdatePanel control unless it is explicitly defined as a trigger.


Following is the example of code with UpdateMode property set to Conditional.


Hope it helps !


Invalid postback or callback argument.

April 14, 2015 Leave a comment

Error :

[ArgumentException: Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %>

Case :

If we re-define/instantiate controls or commands at runtime on every postback, respective/related events might go for a toss. A simple example could be of re-binding a datagrid on every pageload (including postbacks). Since, on rebind all the controls in grid will have a new ID, during an event triggered by datagrid control, on postback the control ID’s are changed and thus the event might not connect to correct control raising the issue.

This can be simply resolved by making sure that controls are not re-created on every postback (rebind here). Using Page property IsPostback can easily handle it. If you want to create a control on every postback, then it is necessary to make sure that the ID’s are not changed.

protected void Page_Load(object sender, EventArgs e)
// Create controls
// Bind Grid

Hope this help !

Operation is not valid due to the current state of the object.

Error : Operation is not valid due to the current state of the object.

When there is a postback with large number of form fields such error occurs.

Stack trace :
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() at System.Web.HttpValueCollection.FillFromEncodedBytes

By default, the maximum value of MaxHttpCollection is 1000.
To solve this error, increase the MaxHttpCollection value. Try adding the following setting in your web.config’s <appsettings> block.


<add key=”aspnet:MaxHttpCollectionKeys” value=”2001″ />


Open FancyBox from Code behind on button click

November 25, 2014 Leave a comment

Add link like following which redirect to popup page that you want to open on button click using fancybox

[1] <a href=”../Scripts/ValidationMessage.aspx” class=”fancybox fancybox.iframe” id=”hiddenlink_confirm” />

Add following js function on head of page along with fancybox script

[2] <script type=”text/javascript”>

function OpenValidationMessagePopup() {
var alink = document.getElementById(“hiddenlink_confirm”);;

[3] Write following code on button click event

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

Dim sb As New StringBuilder()

ScriptManager.RegisterStartupScript(Me.Page, Me.[GetType](), “OpenValidationMessagePopup” + DateAndTime.Now, sb.ToString(), True)

End Sub

Will add some more information to the above steps, hope this help !

Javascript ‘confirm()’ Cancelling Post Back

November 24, 2014 Leave a comment

Problem : Postback is not working on javascript confirm() Click

Solution :

 <asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClick="BtnSubmit_Click"
 OnClientClick="if (!confirm('Are you sure you want to Submit?')) return false;"/>

Hope this help !