Solved

Server side validations not firing

Posted on 2009-04-03
11
404 Views
Last Modified: 2013-11-08
I have an asp.net 2.0 website which works great on the local machine in visual studio 2008.
but when i (deploy, publish, copy) it on the server the validations don't fire in some cases.
We are using IIS 6 and windows server 2003. Can anyone offer any ideas about why this would be the case or where to begin looking for the root cause?

I have programmers who know .Net and I have network guys who know IIS, MS Exchange, etc.  but neither know a lot about the intricacies of deploying web sites. This is very, very bad! Any help would be greatly appreciated.
0
Comment
Question by:ksnider
  • 5
  • 5
11 Comments
 
LVL 10

Expert Comment

by:MaxOvrdrv2
Comment Utility
Hi,

i've worked with both (network and .net framework)... so i probably have a fix for your issue. However, i'd need to know what you mean by "not firing" ? is it the field validators? or the me.IsValid or what? i don't understand what you mean by server-side validations don't fire in some cases?

from what i assume, it's probably not a server setting issue, but a code issue...

thx.
0
 

Author Comment

by:ksnider
Comment Utility
I mean to say required field validator and regular expression validator  are not firing on deployed website but firing on website running from local iis and  VS development server
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
Comment Utility
And this only happens once in a while you say? Not all the time?
0
 

Author Comment

by:ksnider
Comment Utility
No All these validations are in user controls ,I have several user controls but some user controls works properly but some not. I think they shoud be an isssue with IIS setup in developemnt server where client side validations are not enabled using aspnet_regiis -ea or some thing like that.what you say
0
 
LVL 4

Accepted Solution

by:
mahadevan_v earned 400 total points
Comment Utility
Add thie in server side code
Page.Isvalid() in form load this will make all the validation controls work


if (!Page.IsValid) {
    return;
}
else
{
do your regular process....
}
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:ksnider
Comment Utility
Dear mahadevan_v: Thanks for this. It is a good band-aid but does not solve the problem. BTW, it didn't work on form load. We had to put it on button click. But the ASP validation control should work without this work-around. It works fine on other pages, just not in all. In fact, there are places where we repurpose  the exact same code (Investor Briefing Registration and Pilot Briefing Registration, for example) and in works in one case and not the other. Here is a code snippet. Maybe that will help us solve this mystery? Thanks in advance for any additional guidance.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Suitablity.ascx.cs" Inherits="Assets_User_Controls_Suitablity" %>
 

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<style type="text/css">

    .style1

    {

        width: 0;

    }

    .style2

    {

        width: 0;

    }

    .style4

    {

        width: 0;

    }

    .style5

    {

        width: 0;

    }

    .style7

    {

        width: 0;

    }

    .style8

    {

        width: 0;

    }

    .style9

    {

        width: 0;

    }

    .style10

    {

        width: 0;

    }

</style>

<script src="../../../Assets/Documents/PhoneScript.js" type="text/javascript"></script>
 

<asp:Image ID="Image1" runat="server" ImageUrl="~/Assets/Images/Tabbed_Navigation/suitability.png" CssClass="tabs_indicator_bar" />
 

<div class="round_corner_top"><asp:Image runat="server" ImageUrl="~/Assets/Images/calendar_top.png" /></div>
 

<div class="tabs_container tab-02">

<h1>Client Profile and Suitability Questionnaire</h1>

<asp:Label ID="lblPageStatus" runat="server" Text="" Font-Bold="true" ForeColor="Red"></asp:Label>

<asp:MultiView ID="mvSutibilityMain" runat="server" ActiveViewIndex="0">

    <asp:View ID="vSuitabilityInto" runat="server">

        <p class="first">HTML snipped from here.</p>

        <asp:Button ID="btnSuitability" runat="server" Text="&nbsp;" onclick="btnSuitability_Click" CssClass="cont_suit_button" />  

    </asp:View>

    <asp:View ID="vYourInfo" runat="server">  

        <asp:ValidationSummary ID="vsYourInfo" runat="server" Font-Bold="true" ValidationGroup="vgYourInfo" ShowSummary="True"/>

        <%--Primary Client Information --%>

            <asp:Panel ID="pnlInfo" runat="server" GroupingText="Your Information" CssClass="panelHeader">

                <table>

                    <tr>

                        <td class="align_right"><label>First Name*</label></td>

                        <td class="style1" ></td>

                        <td><asp:TextBox ID="txtFirstName" runat="server" class="text_field"></asp:TextBox>

                            <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ValidationGroup="vgYourInfo" ErrorMessage="Please enter your First Name" ControlToValidate="txtFirstName"><asp:Image ID="Image3" runat="server" ImageUrl="~/Assets/Images/Icons/ListBullets/astk.png" /></asp:RequiredFieldValidator>

                        </td>

                    </tr>

                    <tr>

                        <td class="align_right"><label>Last Name*</label></td>

                        <td class="style1"></td>

                        <td><asp:TextBox ID="txtLastName" runat="server" class="text_field"></asp:TextBox>

                            <asp:RequiredFieldValidator ID="rfvLastName" runat="server" ValidationGroup="vgYourInfo" ErrorMessage="Please enter your Last Name" ControlToValidate="txtLastName"><asp:Image ID="Image5" runat="server" ImageUrl="~/Assets/Images/Icons/ListBullets/astk.png" /></asp:RequiredFieldValidator>

                        </td>

                    </tr>

                    <tr>

                        <td class="align_right"><label>Date Of Birth*<br />(MM/DD/YYYY)</label></td>

                        <td class="style1"></td>

                        <td><asp:TextBox ID="txtDateOfBirth" runat="server" class="text_field"></asp:TextBox>

                            <asp:RequiredFieldValidator ID="rfvDateOfBirth" runat="server" ValidationGroup="vgYourInfo" ErrorMessage="Please enter your Date of Birth - MM/DD/YYYY" ControlToValidate="txtDateOfBirth" ><asp:Image ID="Image4" runat="server" ImageUrl="~/Assets/Images/Icons/ListBullets/astk.png" /></asp:RequiredFieldValidator>

                            <asp:RegularExpressionValidator ID="refDateOfBirth" runat="server" ValidationGroup="vgYourInfo" ErrorMessage="Please enter a valid date of birth - MM/DD/YYYY" ControlToValidate="txtDateOfBirth" ValidationExpression="^(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$">*</asp:RegularExpressionValidator>

                        </td>

                    </tr>

                    <tr>

                        <td class="align_right"><label>Country Of Citizenship*</label></td>

                        <td class="style1"></td>

                        <td><asp:TextBox ID="txtCountryOfCitizenship" runat="server" class="text_field"></asp:TextBox>

                            <asp:RequiredFieldValidator ID="rfvCountryOfCitizenship" runat="server" ValidationGroup="vgYourInfo" ErrorMessage="Please enter your Country of Citizenship" ControlToValidate="txtCountryOfCitizenship"><asp:Image ID="Image6" runat="server" ImageUrl="~/Assets/Images/Icons/ListBullets/astk.png" /></asp:RequiredFieldValidator>

                        </td>

                    </tr>

                   

                </table>

            </asp:Panel>  

            <hr />

         <table>

            <tr>

                <td class="align_right">

                    <asp:Button ID="btnSaveProfile" runat="server" Text="Save&nbsp;" onclick="btnSaveProfile_Click" ValidationGroup="vgYourInfo" CssClass="save_button" />

                    <asp:Button ID="btnContinueProfile" runat="server" Text="Save & Continue&nbsp;" ValidationGroup="vgYourInfo" onclick="btnContinueProfile_Click"  CssClass="save_continue_button"/>

                </td>

            </tr>

        </table>

    </asp:View>

         

Open in new window

0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
Comment Utility
client-side validations, ok, that's a javascript issue. But if you handle all of your validation in the code-behind, then this should not matter. What type of controls work, and which don't?

do you have any regexp validators or things like that? empty fields should work properly.

However, if it's all client-side (there is not code-behind to handle the case where client-side would'nt be possible), then it's a browser issue. Not a server issue.

M
0
 
LVL 10

Expert Comment

by:MaxOvrdrv2
Comment Utility
also, after looking at your code above, what part doesn't work? everything? or just the text shows and not the image?
0
 

Author Comment

by:ksnider
Comment Utility
Max- The page renders as it should and it writes the form data tot he database properly. What doesn't work is the validation control. So, basically, wherever it says Required Field Validator or Expression Validator - those are the things that do not work.

The issue isn't browsers. It works when loaded on our development server but not on the main servers. And what is weird is, the same controls will work on certain pages on the main server but not on others. Acts the same in all browsers. It is server specific.

We have three servers - one is the desktop "server" created by Visual Studio. Works perfectly there - on every single page. Then we have two real servers running IIS 6. Acts identical on both. Some pages work and some don't and it is the same pages on both.

Hope that explains it more fully.

BTW, the workaround Mahadevan gave above does work. When we added that to the validation controls, they all work. So that should be worth some partial points. The thing is, we shouldn't have to do that. Why does it work without that in some places and no in others.
0
 
LVL 10

Assisted Solution

by:MaxOvrdrv2
MaxOvrdrv2 earned 100 total points
Comment Utility
Hi,

Yes, I know what field validators are thanks ;) what I was asking is the following: does the "faulty" validators display partial information (just the text but not the image) or simply don't work at all?

As for the IsValid points, if you look at my first post, I include it, saying that the only way to be sure all field validators work is to fire the IsValid command. But no matter. To explain that comment:
IsValid command fires all field validators one by one, and validates them server-side, NOT client side. This ensures that no matter what settings are enabled on browsers, the validators will fire. You can also do them one by one if required. Fieldvalidatorname.isvalid.

In any case, from what you've said, and from having the isvalid fix it, that was your problem originally. You were not validating server-side.

Best practice is always to have the isvalid fire on the save command or button, and not to rely on the OnBlur events (which are client-side).

Cheers

M

0
 

Author Comment

by:ksnider
Comment Utility
Sorry - too many hours with too little sleep! I am with you now. The question about the images threw me. I wasn't thinking of the asterisk images that went with the text. Thanks for your help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now