?
Solved

ASP.NET Major problem with validation in Tab Control

Posted on 2009-12-28
7
Medium Priority
?
803 Views
Last Modified: 2012-06-27
I have a AJAX tab control that is embedded in an update panel. Each panel holds a user control and forward and back buttons to go through the panel like a wizard. Each user control has validation controls to check the proper entry of data. If the data is valid the user should be able to move to the next tab. At the beginning only the first tab in enabled. As the user goes along always the next tab will be enabled when the data is valid. The user can go back via the buttons or click on the tabs.
(As a side note: On each tab change the data is written to a data base to be able to recover from any crashes. The tab that is going to be dispayed will load the data from the database, too.)

My problem is the proper validation. If the user uses the button I set the ActiveTabIndex property of the tab control. Besides the onload events of the page and the user controls it fires the validation controls. If the user clicks a tab the ActiveTabChanged event is catched in the main page code. I can react to it, update the data and the panel is changed, but this time no validation control is fired; only the load events are called.

So I don't know how to trigger the validation controls. Is there a way to fire all of the validation controls on a page at once per code? Is there a way to tell the tab control to trigger the validation controls on an ActiveTabChanged event?

I'm thinking at the moement to do the following workaround: Do all the validation "by hand" in the code. I can define my validation functions in the user control and then call those functions from the main page during the data handling. I just need to find a way to "cancel" the ActiveTabChanged event, so that the user stays on the same tab if the entered data is not valid.

Can anybody help?

Marcus
0
Comment
Question by:MarcusKoch
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:amar31282
ID: 26137585
can you provide the aspx part please
0
 

Author Comment

by:MarcusKoch
ID: 26138524
Hi Amar,

here is the code of the main page. If you need anything else let me know.

Marcus
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="PlaceOrder.aspx.vb" Inherits="PlaceOrder" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register TagPrefix="uc" TagName="ComplPacks" Src="~/controls/ucODCompPackages.ascx" %>
<%@ Register TagPrefix="uc" TagName="DanceCamp" Src="~/controls/ucODDanceCamp.ascx" %>
<%@ Register TagPrefix="uc" TagName="Tickets" Src="~/controls/ucODTickets.ascx" %>
<%@ Register TagPrefix="uc" TagName="Extras" Src="~/controls/ucODExtras.ascx" %>
<%@ Register TagPrefix="uc" TagName="Contact" Src="~/controls/ucODContact.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>
        <asp:Literal ID="litHeader" runat="server" Text="<%$ Resources: Text, OrderRTSF %>" />
    </title>
    <link href="../CSS/RTSOrders.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">

            
    </script>

</head>
<body>
    <form id="frmPlaceOrder" runat="server">
    <div class="ContentCentered">
        <img alt="Rock That Swing Festival Logo" id="IMG1" src="../images/RTSFLogo.gif" width="200"
            height="94" />
        <br />
        <span class="Header">
            <asp:Label ID="lblOrder" runat="server" Text="<%$ Resources: Text, OrderHeadline %>"></asp:Label></span><br />
        <br />
        <div id="divFrame" class="ContentBoxFrame OrderBox">
            <div id="divText" runat="server" class="Inner">
                <h1>
                    <asp:Label ID="lblManageOrdersHeader" runat="server" Text="<%$ Resources:Text, HeaderPlaceOrder %>"></asp:Label></h1>
                <div class="DivBottom">
                    <asp:Label ID="lblManageOrdersDescr" runat="server" Text="<%$ Resources:Text, EnterOrderDescr %>"></asp:Label>
                </div>
                <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" AsyncPostBackTimeOut="600">
                </asp:ToolkitScriptManager>
                <div id="divTabContainer">
                    <asp:UpdatePanel ID="udpTabContainer" runat="server" UpdateMode="Conditional">
                   <%-- <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="" />
                    </Triggers>--%>
                        <ContentTemplate>
                            <asp:TabContainer ID="tabPlaceOrder" runat="server" ActiveTabIndex="0" OnActiveTabChanged="tabPlaceOrder_onClick" AutoPostBack="true">
                                <%--Pannel 0 #############################################################--%>
                                <asp:TabPanel runat="server" HeaderText="<%$ Resources:Text, TabPackages %>" ID="tabPackages">
                                    <ContentTemplate>
                                        <uc:ComplPacks ID="ucComplPacks" runat="server" />
                                    </ContentTemplate>
                                </asp:TabPanel>
                                <%--Pannel 1 #############################################################--%>
                                <asp:TabPanel ID="TabDanceCamp" runat="server" HeaderText="<%$ Resources:Text, TabDanceCamp %>">
                                    <ContentTemplate>
                                        <uc:DanceCamp id="ucDanceCamp" runat="server" />
                                    </ContentTemplate>
                                </asp:TabPanel>
                                <%--Pannel 2 #############################################################--%>
                                <asp:TabPanel ID="tabTickets" runat="server" HeaderText="<%$ Resources:Text, TabTickets %>">
                                    <ContentTemplate>
                                        <uc:Tickets id="udTickets" runat="server" />
                                    </ContentTemplate>
                                </asp:TabPanel>
                                <%--Pannel 3 #############################################################--%>
                                <asp:TabPanel ID="TabExtras" runat="server" HeaderText="<%$ Resources:Text, TabExtras %>">
                                    <ContentTemplate>
                                       <uc:Extras id="ucExtras" runat="server" />
                                    </ContentTemplate>
                                </asp:TabPanel>
                                <%--Pannel 4 #############################################################--%>
                                <asp:TabPanel ID="TabContact" runat="server" Enabled="false" HeaderText="<%$ Resources:Text, TabContact %>">
                                    <ContentTemplate>
                                        <uc:Contact id="ucContact" runat="server" />
                                    </ContentTemplate>
                                </asp:TabPanel>
                            </asp:TabContainer>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                <div class="ButtonsLeft" style="margin-top: 30px;">
                    &nbsp;
                    <asp:Button ID="btnClose" runat="server" Text="<%$ Resources:Text, btnClose %>" OnClick="btnClose_Click"
                        Width="170px" />
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 14

Accepted Solution

by:
amar31282 earned 2000 total points
ID: 26139402
hi

hmm i m not getting very much clear idea about the problem

just making a few poiints first to check

1:have you properly defined the validationgroups..?
2:do you know about Page.IsValid and Page.Validate. If no then read about them they should solve your issue (http://msdn.microsoft.com/en-us/library/aa479045.aspx)
3: have you tried disabling the eventvalidation in the page.


If all above are not applicable then please describe the problem bit in deep.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MarcusKoch
ID: 26139517
I found a piece of information that seemed to get me in the right direction. Only buttons trigger the validation controls automatically. The ActiveTabChanged is only an event and therefore won't trigger the validation controls. Page.Validate was what I was looking for, so that I can trigger the controls in code. I will try this and see if this solves the whole problem. I will post back the results later.
Marcus
0
 
LVL 14

Expert Comment

by:amar31282
ID: 26139539
Page.IsValid  will be more beneficial i suppose then
0
 

Author Closing Comment

by:MarcusKoch
ID: 31670598
I used Validation Groups and it worked fine. The problem that I still couldn't solve was the flicker and double postback that the Update panel around the tab control causes. The validation messages appeared shortly and disapeard immediately. The fix that should fix the fix that Microsoft did to fix a short time bug in old Firefox didn't work.
0
 
LVL 14

Expert Comment

by:amar31282
ID: 26272854
i can resolve the double post back issue also in mozilla .. can u open a post for it.. so that i can reply
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question