PDA

View Full Version : Data binding error



angryrobot
09-11-2006, 08:47 PM
Greetings,

I'm not sure if I found an error or if I'm just doing this wrong. It seems like if a binding error occurs for a control when you are using the error message functionality, the control will not re-bind when you submit after that. It also will not throw the error again, even if you refresh the page so you get the initial non-posted-back page and start again.

Here's the code I'm using:

TestBinding.aspx
-----------------------------
<%@ Page CodeBehind="TestBinding.aspx.cs" Inherits="TestBinding.TestBinding" Language="c#" AutoEventWireup="false" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<html>
<body>
<form runat="server">
<spring:ValidationSummary id="validationSummary" runat="server"/>
Enter a date: <asp:TextBox ID="entry" Runat="server"/>
<asp:Button ID="button" Runat="server" Text="Enter"/>
<p><asp:Label ID="label" Runat="server"/></p>
</form>
</body>
</html>
-----------------------

TestBinding.aspx.cs
----------------------
public class TestBinding : Spring.Web.UI.Page
{
protected TextBox entry;
protected Button button;
private DateTime date;
protected Label label;
protected Spring.Web.UI.Controls.ValidationSummary validationSummary;

public DateTime Date
{
get { return date; }
set { date = value; }
}

protected override void OnInit(EventArgs e)
{
button.Click += new EventHandler(OnSave);

base.OnInit (e);
}

private void OnSave(object sender, EventArgs e)
{
label.Text = "Date is: " + Date.ToString();
}

protected override void InitializeDataBindings()
{
BindingManager.AddBinding("entry.Text", "Date")
.SetErrorMessage("error.Message", "validationSummary");
}
}
----------------

TestBinding.aspx.resx
-----------------------
<root>
<data name="error.Message">
<value>Enter a date</value>
</data>
</root>
--------------------

Steps to reproduce:
1) Load page
2) Enter an invalid date in the text box
3) Press button
4) Page posts back and you see error
5) Click button again
6) No error and page submits fine

Again, I may be doing something wrong. If so, please set me straight!

Thanks in Advance,
Dave

Erich Eichinger
09-12-2006, 10:50 AM
Hi,

are you using the lastest nightly build? This problem has already been fixed.

cheers,
Erich

angryrobot
09-12-2006, 12:43 PM
Nope, I was using the production build. I will try the latest nightly. Thanks.

-Dave