0

I have a custom web part with custom web part property. This web part queries from a list.

The webpart property is "Sorting" and user has to select if sorting is "Alphabetical" or "Custom"

Choosing Alphabetical will arrange contents in my web part alphabetically - No problem with this.

Choosing Custom will arrange contents in my web part by ascending based on the 'Sort' column of my list.

Now, in my web part property validation, I will check if the user selected Custom and 'Sort' column in my list has no values. Then it will throw the WebPartPageUserException showing that the 'Sort' column has null values.

Here's the loophole.
1. I will go to the list, and fill out the 'Sort' column
2. I will edit the property of my web part and choose Custom - this will accept it because the 'Sort' column now have values
3. My web part will now show Custom Sorting
4. I will go back to the list and remove the entries under the 'Sort' column
5. My WebPart will have an error (Web Part Maintenance page)

What should I do so that if ever the loophole steps are done. My custom web part property will set it to 'Alphabetical'? or it will sort it alpahebtically?

2 Answers 2

1

What should I do so that if ever the loophole steps are done. My custom web part property will set it to 'Alphabetical'? or it will sort it alpahebtically?

Up to you, what does the customer want to happen?

You'll get that Web Part Maintenance Page error as it currently as, personally I would handle the exception and present a nicer error message in place of the web part.

0

What I did is that in my Page_Load, I will check if the list has Null values under the 'Sort' column.

If it has null values, then I will set it to Alphabetical, in this way I will not be encountering the Web Part Maintenance Page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.