RadTabStrip and Validation issues...

0 Answers 36 Views
TabStrip
Scott
Top achievements
Rank 1
Iron
Iron
Scott asked on 23 Oct 2023, 06:51 PM

I can't seem to get RadTabStrip to do validation the way I want it to...

I have a RadTabStrip with a RadMultiPage and several RadPageViews

Inside each RadPageView id a FormView

I also have a Validator on a field outside of the RadTabStrip.

Whenever I click on a Tab for the RadTabStrip the validation ErrorMessage for the validator outside of the TabStrip disappears.

What I would like to have happen when selecting a Tab in the Tab strip

1)  CustomValidator Messages outside of the tabstrip continue to show their ErrorMessage

2) Any controls within the newly selected tab have their CustomValidators server side methods called.

 

I have tried setting the RadTabStrip ValidationGroup to be the same as all the CustomValidators, ValidationRequestMode to Enabled... but that did not do anything.

I also tried calling Page.Validate() in the TabClick event.  However, that has the unpleasant effect of allways putting me on the first tab and not the tab I clicked on.

What can I do in order to get the functionality described in items #1 and #2 ?

 

Scott
Top achievements
Rank 1
Iron
Iron
commented on 23 Oct 2023, 08:29 PM

TabStrip behaves a little weird IMO.

1) If do not have a defined TabClick event, clicking on a Tab automatically shows the associated PageView

2) once you define a TabClick event the TabStrip does not automatically enable the clicked Tab; neither is the PageView Automatically shown

3) Setting the TabStrip.SelectedIndex to index of the desired PageView only selects the TabStrip and not the associated PageView... weird IMO, and I didn'f see this in the documentaiton.

In conclusion in order to get both define a TabClick event and select the Tab and Page you must...

1) Set your previous PageView.Selected to false

2) set your new PageView.Selected to true

3) set your TabStrip.SelectedIndex to the indexof the page in #2

Here is the code I used to both re-trigger the validations and show the correct tab and page...


protected void tabEditPerson_TabClick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)
    {
        Page.Validate();  // re-trigger the validations
        Telerik.Web.UI.RadTab tab_clicked = e.Tab;
        
        // really only need to det the previously selected PageView to false, but this way I don't have to keep track of previous selected PageViews
        pvJob.Selected = false;
        pvPersonal.Selected = false;
        pvTermination.Selected = false;
        pvHistory.Selected = false;
        pvSalary.Selected = false;
        pvNotifications.Selected = false;

        tab_clicked.PageView.Selected = true; // Set the pageview to selected
        tabEditPerson.SelectedIndex = tab_clicked.Index;  // set the TabStrip to the Selected Tab
    }
Is there a better way to do this?
Attila Antal
Telerik team
commented on 26 Oct 2023, 11:29 AM

Hi Scott,

RadTabStrip is just a container such as a div element and it does not have Validation functionality nor is related to validations. Because validators do not work as intended, that might be due to the way everything is built/constructed.

The code you shared is just a few lines that are executed when a button is clicked. To have a better understanding, we would need to see the complete implementation of the tab strip and validators.

Please share all the code or instructions that will help us replicate the issue and from there, we will be able to debug it for you.

No answers yet. Maybe you can help?

Tags
TabStrip
Asked by
Scott
Top achievements
Rank 1
Iron
Iron
Share this question
or