Note that there are some explanatory texts on larger screens.

plurals
  1. POAllow a webpart with valid data to save while displaying validation errors for other webparts
    primarykey
    data
    text
    <p>I have an ASP.Net page made up of several web parts (C# - ascx). By definition, I don't know how many web parts are on the page. I don't control the page, only my parts which happen to be added to this page. There could be parts by other authors on the same page, but that's not important right now.</p> <p>Most web parts are for displaying and editing information. Each such part has its own ValidationGroup and ValidationSummary, and its own Save button. The current requirements call for each part to be saved separately. These parts may all be the same or chosen from just three varieties, but are configured to display different subsets of data from the database. Each part may have required fields, using a RequiredFieldValidator.</p> <p>Another type of web part serves as a header/summary. It will almost always appear once, though it could appear anywhere on the page or (possibly) appear more than once.</p> <p>What I want to do is display a summary in the header of which of the other parts on the page have unmet requirements. (This would include jump-links to the appropriate part, but I know how to do that.) This code from the header part lets me determine if any of the parts have a validation error:</p> <pre><code>bool foundAnyInvalid = false; Dictionary&lt;string, bool&gt; Parts = new Dictionary&lt;string, bool&gt;(); foreach (System.Web.UI.WebControls.BaseValidator val in Page.Validators) { if (!Parts.ContainsKey(val.ValidationGroup)) { Parts.Add(val.ValidationGroup, true); Page.Validate(val.ValidationGroup); } if (!val.IsValid) { Parts[val.ValidationGroup] = false; foundAnyInvalid = true; } } </code></pre> <p>...but it forces all the parts to be validated at once. As a result, individual parts can't be saved if other parts have failed requirements.</p> <p>What I want to achieve is:</p> <ul> <li><p>The header always displays a list of parts which have missing validations</p></li> <li><p>All detail parts display the typical red * next to fields which are required</p></li> <li><p>If the Save in a particular detail part is clicked, the Validator.Message and ValidatorSummary for that part will display the typical messages. ("Foo is required")</p></li> <li><p>If the user clicks save on a part that is valid, the data should save even if other parts are still missing data.</p></li> </ul> <p>As a secondary and somewhat related issue, the header includes a "go back" link. I want to disable this link as long as any part is not valid and saved. If this is too much to bite off in one question, I'll ask that separately, but I thought I should mention it in case it affects the answers offered. (I may have to validate this one by checking the database instead of the form.)</p> <p>I would consider making all the parts save if any Save button is clicked, but I'm not immediately sure how to do that. If I'm coming at this page the wrong way, please don't hesitate to tell me that, too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload