Welcome Guest Search | Active Topics | Sign In | Register

Call to eo_Callback is causing page validation Options
Mike Wynn
Posted: Tuesday, October 2, 2007 1:55:48 AM
Rank: Advanced Member
Groups: Member

Joined: 8/24/2007
Posts: 130
Hi, I have a page that uses a CallbackPanel. This panel gets refreshed at various times via the eo_Callback method.

The poblem I am having, is that each time the panel gets refreshed, page validation occurs. This is not something I want to happen, so am wondering if there is any way to prevent this from happening?

Setting the 'CausesValidation' property of all postback controls on the page to false does not seem to make any difference, and I do not see this property on the CallbackPanel.
eo_support
Posted: Tuesday, October 2, 2007 6:50:50 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

As far as I know, eo_Callback does not trigger validators. If you use trigger to trigger it, it will. So I am not sure the validators got triggered for you. Can you recreate the issue in a separate page and then post the reproducing code?

Thanks
Mike Wynn
Posted: Wednesday, October 3, 2007 2:37:33 AM
Rank: Advanced Member
Groups: Member

Joined: 8/24/2007
Posts: 130
The following code is a very simple example that illustrates the problem:

ASPX file...

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="BulkUploadPOC2.WebForm2" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server"></head>
<body>
<form id="form1" runat="server">
<div>
<eo:CallbackPanel ID="callbackPanel" runat="server" Height="150px" Width="200px">
<asp:CustomValidator ID=validator runat=server></asp:CustomValidator>
<asp:Button ID="Button1" runat="server" Text="Button" CausesValidation=false OnClientClick="eo_Callback('callbackPanel');" />
</eo:CallbackPanel>
</div>
</form>
</body>
</html>

Code Behind File....

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BulkUploadPOC2
{
public partial class WebForm2 : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// initialise validator
validator.ServerValidate += new ServerValidateEventHandler(validator_ServerValidate);
}

private void validator_ServerValidate(object source, ServerValidateEventArgs args)
{
string str =
"This method always gets called when the button is clicked, even though 'CausesValidation' is set false.";
}
}
}


As long as the button calls eo_Callback, validation method validator_ServerValidate always gets called, despite the fact that I have set 'CausesValidation' to false. If I remove the call to eo_Callback, then the validation method does not get called.
eo_support
Posted: Wednesday, October 3, 2007 7:10:13 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

Sorry that we were looking at the client side behavior. eo_Callback does trigger server side validation logic. Server side validation logic is triggered by ASP.NET when it can not find a "source control" that can be "responsible" for the postback (when it can find a "responsible" control, it lets that control to decide). When you use a trigger, the triggering control is regarded as "responsible", however when you use eo_Callback on another server control, it's hard to say whether the control or the CallbackPanel is responsible, so nobody is actually regarded responsible in this case.

One of the reasons that we decided not to have a CausesValidation on the CallbackPanel was that when you use a trigger, it's the triggering control's CausesValidation that should be honored, the CallbackPanel supposes to be transparent. So having a CausesValidation on the CallbackPanel would just confuse user at this case.

In order to avoid the problem, you can override Page.Validate function. You can do something like:

Code: C#
public override void Validate()
{
    if (!callbackPanel.IsCallback)
        base.Validate();
}


That should skip validation when it's a callback.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.