Hello,
I'm still fairly new to ASP.Net, so I hope someone can point me in the right direction. I created a test project to examine the use of the ASP.Net AJAX components. I created a simple page with the following structure
Page
- Label: Shows current date/time
- Button: Has a click event with no code, just to trigger the time change
- Update Panel 1
- ListBox
- 2 buttons: code to move items in listbox up and down
- Update Panel 2
- TextBox
- Button: has a click even with no code to trigger update panel
- Asp Required Field Validator: for the TextBox
- ValidatorCalloutExtender: for the required field validator
So, here's my question. The way I understood it, by putting the items in an update panel, events triggered in that panel only updates the panel. So, for example, by pushing one of the buttons in UpdatePanel1, I wouldn't trigger the label on the main page to show the updated time. That part seems to work ok. However, when I added the validation items into the 2nd update panel, no matter what I do, the validation fires if the field is blank. Is that simply a function of validation, or is there something I need to add somewhere that would force UpdatePanel2 to fire on its own? Thanks.
Try making your UpdatePanel conditional:
<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional">
Actually, did some more research and found that there's apparently a bug with validation and AJAX UpdatePanel. See here for the fix:
http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx
It also helped me to use the ValidateGroup property on the button and the RequiredFieldValidator
No comments:
Post a Comment