Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Server side validations not firing

Posted on 2009-04-03
11
Medium Priority
?
456 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
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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

886 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