Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8081563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:46:08+00:00 2026-06-05T16:46:08+00:00

In my application I have an edit profile page which you can see below;

  • 0

In my application I have an edit profile page which you can see below;

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.master" 
Inherits="System.Web.Mvc.ViewPage<SHP.WebUI.Models.EmployeeViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Edit
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <% using (Html.BeginForm("Edit", "Employee"))
    {%>
        <%: Html.AntiForgeryToken()%>
        <%: Html.ValidationSummary(true)%>
        <fieldset>
            <legend>Edit Employee</legend>
             <% if (TempData["Message"] != null && TempData["Message"].ToString().Length > 0)
             { %>
                <p class="success">
                   At <% Response.Write(DateTime.Now.ToString("T")); %> 
                   you entered <%: TempData["Message"]%>.
                </p>
             <%} %>
            <table class="groupBorder" id="editTable">
                <tr>
                    <td style="text-align: right;"><%: Html.LabelFor(model => model.Employee.CompanyId)%></td>
                    <td>
                        <%: Html.DropDownListFor(model => model.Employee.CompanyId, Model.CompaniesSelectList)%>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: right;">
                <%: Html.LabelFor(model => model.Employee.EmployeeNumber)%>
                   </td>                    
                    <td>
                <%: Html.TextBoxFor(model => model.Employee.EmployeeNumber,
                    new { maxlength = "4", style = "width:35px;text-transform: uppercase;" })%>
                <%: Html.ValidationMessageFor(model => model.Employee.EmployeeNumber)%>
                    <span class="error" id="errorMessage">
                        <% if (TempData["ErrorMessage"] != null)
                        { %>
                            <%: TempData["ErrorMessage"].ToString()%>
                        <% } %>
                    </span>
                    </td>
                </tr>

                <tr>
                    <td style="text-align: center;padding-top:20px;" colspan="2">
                    <input type="submit" value="Save"  id="btnSubmit"/></td>
                </tr>
            </table>
        </fieldset>

    <% } %>

    <div>
        <%: Html.ActionLink("Back to List", "List")%>
    </div>

    <script language="javascript" type="text/javascript">


        $(document).ready(function() {


            $("#Employee_CompanyId").change(function () {
                validateEmployeeNumber();
            });

            $("#Employee_EmployeeNumber").change(function () {
                validateEmployeeNumber();
            });
        });

        function validateEmployeeNumber() {
            var employeeNumber = $("#Employee_EmployeeNumber").val().toUpperCase();
            $("#Employee_EmployeeNumber").val(employeeNumber);
            if (employeeNumber.length == 0) {
                $('#errorMessage').text("Employee Number Required");
            }
            if (employeeNumber.length > 0) {
                $('#errorMessage').text('');
                $('#btnSubmit').attr("disabled", false);
                var companyId = $("#Employee_CompanyId").val();
                var employeeId = $("#Employee_EmployeeId").val();
                $.ajax({
                    data: { companyId: companyId, employeeNumber: employeeNumber, employeeId: employeeId },
                    dataType: "text",
                    success: function (data) {
                        if (data.length > 0) {
                            $('#errorMessage').text(data);
                            $('#btnSubmit').attr("disabled", true);
                        }
                    },
                    type: "POST",
                    url: '<%= Url.Action("ValidateEmployeeNumber", "Employee")%>'
                });
            }
        }
        </script>


</asp:Content>

The controller used here is as follows;

   [HttpPost]
    [Authorize(Roles = "Administrator, ManagerAccounts, ManagerIT")]
    public string ValidateEmployeeNumber(string companyId, string employeeNumber, string employeeId = null)
    {
        var cid = 0;
        var flag = int.TryParse(companyId, out cid);
        if (!flag)
        {
            return string.Empty;
        }

        var eid = 0;
        if (employeeId != null)
        {
            flag = int.TryParse(employeeId, out eid);
            if (!flag)
            {
                return string.Empty;
            }
        }

        if (Employee.ValidateEmployeeNumberFormat(employeeNumber) == false)
        {
            return "Invalid format";
        }

        var employeeNumberExists = Employee.GetEmployeeByEmployeeNumber(cid, employeeNumber, eid);
        return employeeNumberExists ? "Invalid Employee Number already in use." : string.Empty;
    }

This page itself has been edited to show the bits I am interested in.
The page is to enable the administrator to edit the profile of the employee, including the employee number.
The Ajax call to the server is to check whether the employee number is unique.
Now on my developer machine this works on all servers; development, test and production. But for some people working on other machines it does not work. When they try to edit the employee number on the production server, they suddenly get lots of red text of javascript appear immediately after the AJAX call.
Why does this happen and how can this fixed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:46:11+00:00Added an answer on June 5, 2026 at 4:46 pm

    I found the answer.
    The problem was caused by the authorise attribute on the controller method. This attribute excluded some users and when they used the Ajax service, they got this error. I have to say that the sympton of the problem, lots of javascript text in red displayed on the screen, did not give anything away as to what the problem couls have been.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an webView in a Cocoa application which I edit the contents programatically.
In my application I have a login page were the user can log in.
In my application, in an activity i have 4 edit Text fields and a
I have an application that uses MSWord automation to edit some documents, after they
We have an application that allows users to add/edit/replace/delete content (text, images, swfs, mp3s,
I have an application that allows the user to edit multiple text fields and
I am writing a PHP application that will have the ability to edit settings
I see an application have used Log.info = some info where are these logs
In my console application have an abstract Factory class Listener which contains code for
We have just finish to profile our application. ( she's begin to be slow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.