Link to home
Start Free TrialLog in
Avatar of SweatCoder
SweatCoderFlag for United States of America

asked on

ASP.NET ValidationSummary ShowMessageBox="True" ShowSummary="False"

I'm using a ValidationSummary on my asp.net 4.0 page. I have ShowMessageBox="True" ShowSummary="False". This is supposed to pop a javascript alert with all the validation error messages, and also NOT show the error messages (summary) directly on the web page, in the div or however they do it. It does show the alert as expected but also shows the messages inline in the page--it shouldn't.

I have another asp.net page that is set up the same way, but it works correctly. Also has ShowMessageBox="True" ShowSummary="False", but it shows the alert and hides the inline text--which is correct.

I can't figure out why it works on one page on not on the other, with same options in place.
Avatar of silemone
silemone
Flag of United States of America image

can you post both validation tags completely so I can compare them...i have used validations many times, so i should be able to help.
Well see this link...and make sure the settings are correct with both the validator and the validationsummary.

http://msdn.microsoft.com/en-us/library/1ze30x3t(v=vs.71).aspx
Make sure you're using ErrorMessage property instead of the Text property to store you error message in the validator control also.
Avatar of SweatCoder

ASKER

This one doesn't work right:

<asp:validationsummary id="summInvoiceValidator" ValidationGroup="group1"
                            runat="server" HeaderText="MyApp" ShowMessageBox="True" ShowSummary="False" DisplayMode="List">  
</asp:validationsummary>

This one does work right:

<asp:validationsummary id="ValSumAF" ValidationGroup="group2"
            runat="server" HeaderText="MyApp" ShowMessageBox="True" ShowSummary="False" DisplayMode="List">  
</asp:validationsummary>  

These 2 are on different aspx pages.

silemone: I'm interested to know your ideas.
silemone: As far as I can see, I'm doing everything correctly. Still no joy.
Ok...and does the <Required validation  (whichever  you're using) use the same ValidationGroup?

Does it have ErrorMessage set (NOT Text property, but ErrorMessage propert)?  Is the Display set to None?
ASKER CERTIFIED SOLUTION
Avatar of silemone
silemone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If your problem continues, i must advise you to create a small mini-version of this program with one field, one button, etc. and get it to work.
>>

remember there will be 3 components:

1) <asp:Textbox...>
2) <asp:RequiredValidation...>
3) <asp:ValidationSummary...>

2) must have ValidationGroup the same as 3)
2) must have ErrorMessage Property Set
2) must have Display set to 'None'
2) must have the ControlToValidate set to 1) ID

1) 2) 3) -> must have distinct IDs and runat='server'

Yes...I'm doing all those things. That's why I'm stumped.
I never solved the root problem, but I found a nice workaround. I simply wrapped my validators in this:

<div style="display:none">

</div>

All I want is the client-side alerts for validation, so this works great.
Silemone, I don't think your post solved my problem (it never did get solved), but my workaround is good and I want to close this out.
Avatar of Dave Sexton
Dave Sexton

I think the reason is that the ShowMessageBox attribute wants true or false not True or False. The one case where it works for you is because the default is true, both of your examples are technically not working.