Validator problem in UpdatePanel

S

SAL

Hello,
Yes, I've read that Validator controls are not compatible inside
updatePanels. I have downloaded the Validators.dll file and added the
tagMapping to my web.config file so I'm thinking the validators should work
right???
ClientSideScript is disabled.

Here's the gist of the problem.

I have an app with a GridView, in an update panel, and a DetailsView, inside
another update panel. The DetailsView is used for both inserting new records
and editing existing records.

There a dropdownlist in the updatepanel for inserting/editing and when a
user selects an item from this dropdown, a dropdown inside the DetailsView
populates with the appropriate items for that category.
If the user then clicks the insert link in the DetailsView, the
requiredfieldvalidator fires off showing it's text and it's error message
displays in the ValidationSummary control. This works great.
However, if a user clicks the Editing button in the top UpdatePanel in one
of the rows of the GridView and then clicks the cancel button of the
DetailsView, validation appears to still work but the validators error
message and text no longer will display.
This same behavoir shows up for the CustomValidator I have for the same
field in the DetailsView.

Is there a way to work around this issue or is it just something in the way
that I've configured my application?
I've created a Repro project can e-mail it. It was too large for this post a
little over 1/2 mb.

Steps to re-create the issue.
Sequence 1
open the project and run it. I have it set up to startup using cntyAssetId =
1709
select an item from the dropdownlist just above the details view.
click the insert button and the RequiredFieldValidator displays its text and
the ValidationSummary control displays the error msg.

Sequence 2
Click the pencil icon for one of the rows in the GridView. The DetailsView
populates with the record.
Click the cancel button in the Detailsview
The DetailsView returns to Insert mode.

Repeat Sequence 1

Sequence 3
To test for the CustomValidator, repeat Sequence 1 and enter a non-valid
StmFacilityClkId like 999999.
The CustomValidator works as expected.
Repeat Sequence 2
Repeat Sequence 3 and the validator, while still preventing a record from
being added, the validators text and error message no longer display.

Any help is much appreciated on this. I googled and googled on it and tried
lots of things.

SAL
 
A

Allen Chen [MSFT]

Hi SAL,

Could you send me that demo project? I'd like to repro it on my side first.

My email is (e-mail address removed). Please update here after sending the
project in case I missed that email.


Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Allen Chen [MSFT]

Hi SAL,

I've received the project. Thanks.

I did following test:

1. Remove the UpdatePanel. This issue can still be reproduced.

2. I delete your code one by one and finally get a concise demo that can
reproduce this problem. It turned out it's caused by the use of the
SessionParameter. If you try step 1 to remove the UpdatePanel and use
following code instead it works fine:

<asp:ObjectDataSource ID="dsStormInsert" runat="server"
DeleteMethod="Delete" EnableViewState="true"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetStormValueByStormValueId"
TypeName="StormValueBLL"
UpdateMethod="UpdateStormTable">
<DeleteParameters>
<asp:parameter Name="stormValueid" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asp:parameter Name="id" Type="Int32" />
<%-- <asp:SessionParameter Name="id"
SessionField="stormValueId" Type="Int32" />--%>
</SelectParameters>
</asp:ObjectDataSource>

Protected Sub ManageEdit(ByVal rowNumber As Integer)

Dim svalueId As Integer = gvStormDetail.DataKeys(rowNumber).Value
If svalueId > 0 Then
'Session(STORMVALUEID) = svalueId
dsStormInsert.SelectParameters(0).DefaultValue = svalueId

dvStormInsert.ChangeMode(DetailsViewMode.Edit)
Me.ddlAssetType.Enabled = False
Me.ddlAssetType.SelectedValue = GetStormAssetId(svalueId)
End If
End Sub

Please try it and let me know if it works(If UpdatePanel is added it will
throw an exception. I need more time to look into your code to see what the
problem is).

Regards,
Allen Chen
Microsoft Online Support
 
S

SAL

Hmmm,
I can see where you changed the code. Having this particular updatepanel is
a really nice feature we'd like to keep so we don't have to do a complete
page update.
I can see where you changed the code from a session parameter to using the
DefaultValue parameter. Can you please let me know if you find the cause of
this problem? I also wouldn't mind knowing why the session parameter is
causing a problem.

Thanks Allen
S
 
A

Allen Chen [MSFT]

Hi SAL,

Thanks for your update. After debugging your code for a while I finally
found the root cause of this issue. It's caused by disabling the ViewState.

If ViewState is disabled in the ObjectDataSource control DetailsView will
be rebound. This happens after the validation control's work. So the
expected layout of the DetailsView get lost due to the rebinding.

To solve this problem. You can enable the ViewState of the following two
controls:

<asp:UpdatePanel ID="upInsert" runat="server" EnableViewState="true"

<asp:ObjectDataSource ID="dsStormInsert" runat="server"
DeleteMethod="Delete" EnableViewState="true"

It should work.

Please have a try and let me know if you need further assistance.

Regards,
Allen Chen
Microsoft Online Community Support
 
S

SAL

Wow, what a simple solution and man I tried everything (I thought)!
Thanks so much for helping me solve this one Allen, much appreciated

S
 
A

Allen Chen [MSFT]

Hi SAL,

You're welcome. Have a nice day!

Regards,
Allen Chen
Microsoft Online Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top