I have an UpdatePanel which has a Repeater inside. Each ItemTemplate of Repeater containers a Textbox and its RequiredValidator. Here is the code
<atlas:UpdatePanel ID="ButtonLabelContainerPanel" runat="server">
<ContentTemplate>
<asp:Repeater ID="ButtonLabelContainer" runat="server">
<ItemTemplate>
<div id="LabelRow" class="formRow">
<label id="Label1" for="ButtonText" runat="server"><%=Resources.InterfaceKitsResource.ButtonLabel %></label>
<asp:TextBox ID="ButtonText" Text="<%# Container.DataItem %>" runat="server" />
<asp:RequiredFieldValidator ID="ButtonTextValidator" ControlToValidate="ButtonText" ValidationGroup="CreateButtonImageValidationGroup" Text="Button Label is required" runat="server" Display="Dynamic" />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="addLabel" EventName="Click" />
</Triggers>
</atlas:UpdatePanel>
Notice the Validator has a "ValidationGroup".. somewhere else on the page, I have a button (not part of the trigger) which will be clicked and has the same "ValidationGroup"...
The issue is.. all empty textbox within the repeater shows up the error message EXCEPT the first textbox.
What am I doing wrong?
hello.
can you build a repro page and post it here?
Yeah, here is a watered down version of what i have
-----
<%@. Page Language="C#" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindButtonContainer();
}
}
private void BindButtonContainer()
{
ArrayList ButtonLabelArray = new ArrayList();
ButtonLabelArray = getButtonTextList(false);
ButtonLabelArray.Add("");
ButtonLabelContainer.DataSource = ButtonLabelArray;
ButtonLabelContainer.DataBind();
}
private ArrayList getButtonTextList(bool createHover)
{
ArrayList ButtonLabelArray = new ArrayList();
foreach (RepeaterItem item in this.ButtonLabelContainer.Items)
{
TextBox mytextBox = (TextBox)item.FindControl("ButtonText");
ButtonLabelArray.Add(mytextBox.Text);
}
return ButtonLabelArray;
}
protected void AddButtonLabel(object sender, EventArgs e)
{
BindButtonContainer();
}
protected void BindOutputImages(object sender, EventArgs e)
{
Output.DataSource = getButtonTextList(false);
Output.DataBind();
}
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<atlas:ScriptManager ID="scriptmanager1" EnablePartialRendering="true" runat="Server" />
</head>
<body>
<form id="form1" runat="server">
<div id="RepeaterSection">
<atlas:UpdatePanel ID="ButtonLabelContainerPanel" runat="server">
<ContentTemplate>
<asp:Repeater ID="ButtonLabelContainer" runat="server">
<ItemTemplate>
<div id="LabelRow" class="formRow">
<label id="Label1" for="ButtonText" runat="server"><%=Resources.InterfaceKitsResource.ButtonLabel %></label>
<asp:TextBox ID="ButtonText" Text="<%# Container.DataItem %>" runat="server" />
<asp:RequiredFieldValidator ID="ButtonTextValidator" ControlToValidate="ButtonText" ValidationGroup="CreatButtonGroup" Text="Button Label is required" runat="server" Display="dynamic" />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="addLabel" EventName="Click" />
</Triggers>
</atlas:UpdatePanel>
<asp:LinkButton ID="addLabel" CssClass="addFormRow" Text="Add Another" OnClick="AddButtonLabel" runat="server" />
</div>
<div id="output">
<asp:Button ID="CreateButtons" runat="server" OnClick="BindOutputImages" ValidationGroup="CreatButtonGroup" Text="Create Button" />
<atlas:UpdatePanel ID="OutputPanel" Mode="Conditional" runat="server">
<ContentTemplate>
<atlas:UpdateProgress ID="OutputInProgress" runat="server">
<ProgressTemplate>
Working...
</ProgressTemplate>
</atlas:UpdateProgress>
<asp:Repeater ID="Output" runat="server">
<ItemTemplate>
<div class="generatedButton">
<%# Container.DataItem %>
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="CreateButtons" EventName="Click" />
</Triggers>
</atlas:UpdatePanel>
</div>
</form>
</body>
</html>
------
To test this..
1) fill in something in the first textbox, click on "Add Another"
2) fill in something in the second textbox click on "Add Another" again
3) click "create button"
Now you should see the text you entered on the bottom correct?
4) get rid of the text in the second texbox
5) click "create button"
The text of the requiredvalidator shows up as expected.. But now try this...
6) get rid of the text in the first textbox as well...so now you have both empty text boxes
7) click "create button"
See the problem? the requiredvalidator text next to the first textbox did not show up.
The only time it shows up for the first textbox is when it's the ONLY textbox in the repeater. When page load, without entering anythign, just one textbox, click "create button". It'll work.
This only stops working when there are multiple itmes in the repeater.
and oh btw,
the display="dynmaic" stopped functioning as well.
say
1) enter soemthign in first textbox
2) click "add another"
3) without entering anything in the second textbox, click "create button"
you'll see the red requiredvalidator error next to the the second box. now try
4) to fill something into the secondbox,
5) tab away to "create button"
normally without updatepanel, the red text will disappear right away, but now it doesn't.
I'm using firefox 1.5
hello.
that's weird. i've followed the steps you've mentioned in your previous post and here i get the error on the first validator too! if i fill the textbox and hit tab, the error goes away, so i really can't reproduce the errors you're having...btw, i've tested it in IE 6 and firefox 1.5 too.
can you repro those errors on another machine? i can try to look at it tomorrow at work, where i have win 2003 server, but here with xp sp2 and the march ctp of atlas, everything went well.
Hello Luis,
Yeah, I've deployed onto an windows 2003 server with march CTP, i get teh same problem.
Everything else works except the first validator and "display='dynamic'". I'm guess this is a bug in Atlas. Worst to worst, I'll have to resolve to traditional javascript dom for this matter. But if you have any insight, please do post here.
Thanks a a lot!
hello again.
well, i've tried here at work and guess what? well, validation wasn't working well with firefox. so, why was it working at home: simple, because i've changed the atlas.js code that i'm using in my pages.
the problem i was getting was related with the way validation was working. after adding elements to the page, i was allways getting a postback. so, several things go wrong here:
1. the update panel isn't working properly with validation because the method that submits the form doesn't verify the state of the validators before doing the submit (i've pointed this problem in several post here)
2. after copying the js files used on the client side validation, i noted that the number of validators on the page was allways 1. using fiddler i could see that they were returning it correctly (there was as script section with 2 validators on it). it was then that i recalled having found a bug related with the way firefox interprets the script nodes returned from the server side. the problem is that to firefox \n is a node while it's discarded in IE (i really don't know which implementation is correct; this is just an observation related with the way both browsers behave). so, the problem was that firefox was executing "\n" (which simply doesn't do anything) while ie was executing the var Page_Validators ... line which redefines the validators arrays.
how to solve these? i've presented a simple solution to number 1 in previous posts
related with number 2, i say that the _updatescripts method of the atlas.js (or atlasruntime.js) has to be modified so that it has this line:
if
(xmlScriptNode.childNodes.length != 0) {for (var c = xmlScriptNode.childNodes.length - 1; c >= 0; c--) {
var nodeType = xmlScriptNode.childNodes[c].nodeType;
if ((nodeType == 3) || (nodeType == 4) || (nodeType == 8)) {
text = xmlScriptNode.childNodes[c].nodeValue;
if( text =="\n")
{
continue;
}
break;
}
}
}
the bolder bigger lines solve the interpretation issue on firefox. hope this helps.
Hi Luis,
This problem with scripts in Firefox is fixed in the April CTP, which we will be releasing this month (obviously!).
Thanks,
Eilon
howdy again!
that's great! thanks again.