?
Solved

Server side validations not firing

Posted on 2009-04-03
11
Medium Priority
?
452 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 10

Expert Comment

by:MaxOvrdrv2
ID: 24065654
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
ID: 24066400
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
ID: 24067841
And this only happens once in a while you say? Not all the time?
0
Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

 

Author Comment

by:ksnider
ID: 24068214
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 1200 total points
ID: 24068489
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
 

Author Comment

by:ksnider
ID: 24069034
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
ID: 24073834
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
ID: 24073840
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
ID: 24074102
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 300 total points
ID: 24079106
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
ID: 24079179
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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 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