Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Validator problem in UpdatePanel

Reply
Thread Tools

Validator problem in UpdatePanel

 
 
SAL
Guest
Posts: n/a
 
      12-12-2008
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



 
Reply With Quote
 
 
 
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      12-15-2008
Hi SAL,

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

My email is http://www.velocityreviews.com/forums/(E-Mail 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 Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#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/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
SAL
Guest
Posts: n/a
 
      12-15-2008
Hi Allen,
I'm e-mailed the repro project to you.. Thanks

S

"Allen Chen [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi SAL,
>
> Could you send me that demo project? I'd like to repro it on my side
> first.
>
> My email is (E-Mail 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 Removed).
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/en-us/subs...#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/subs.../aa948874.aspx
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>



 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      12-16-2008
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>
<asparameter Name="stormValueid" Type="Int32" />
</DeleteParameters>
<SelectParameters>
<asparameter 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

 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      12-16-2008
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

"Allen Chen [MSFT]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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>
> <asparameter Name="stormValueid" Type="Int32" />
> </DeleteParameters>
> <SelectParameters>
> <asparameter 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
>



 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      12-17-2008
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

 
Reply With Quote
 
SAL
Guest
Posts: n/a
 
      12-17-2008
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
"Allen Chen [MSFT]" <(E-Mail Removed)> wrote in message
news:KMrz2K$(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Allen Chen [MSFT]
Guest
Posts: n/a
 
      12-18-2008
Hi SAL,

You're welcome. Have a nice day!

Regards,
Allen Chen
Microsoft Online Support

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validator not working when inside UpdatePanel Nathan Sokalski ASP .Net 13 09-08-2010 03:21 PM
Validator not working when inside UpdatePanel Nathan Sokalski ASP .Net Web Controls 12 12-09-2009 05:39 PM
Triggering an UpdatePanel with a trigger located outside of the UpdatePanel Nathan Sokalski ASP .Net 1 06-15-2009 06:23 PM
refresh an updatePanel in an other updatePanel fran_j_diaz@yahoo.fr ASP .Net 3 08-08-2007 06:30 AM
Struts Validator - creditCard validator smrimell@gmail.com Java 4 02-13-2007 08:32 PM



Advertisments