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 8136449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:45:44+00:00 2026-06-06T10:45:44+00:00

I am using jquery in my asp.net website. It was working fine in my

  • 0

I am using jquery in my asp.net website. It was working fine in my local system. But when I published it in the server it is not working. My jquery code is as follow,

    $("#<%=btnSubmit.ClientID %>").click(function (ev) {
    ev.preventDefault();
    $(this).attr("disabled", true);
    if ($("#<%=ddlLetterType.ClientID %>").val() == "-1") {
        alert("Please select a letter.");
        $("#<%=ddlLetterType.ClientID %>").focus();
        $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
        return false;
    } else if ($("#<%=ddlLetterType.ClientID %>").val() == "1") {
        if ($("#<%=ddlEmbassyCountry.ClientID %>").val() == "-1") {
            alert("Please select an Embassy Country.");
            $("#<%=ddlEmbassyCountry.ClientID %>").focus();
            $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
            return false;
        } else if ($("#<%=ddlTravelCountry.ClientID %>").val() == "-1") {
            alert("Please select a Travel Country.");
            $("#<%=ddlTravelCountry.ClientID %>").focus();
            $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
            return false;
        } else if ($("#<%=txtEmbassyAddress.ClientID %>").val() == "") {
            alert("Please enter embassy address.");
            $("#<%=txtEmbassyAddress.ClientID %>").focus();
            $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
            return false;
        } else if ($("#<%=txtPassportNo.ClientID %>").val() == "") {
            alert("Please enter passport no.");
            $("#<%=txtPassportNo.ClientID %>").focus();
            $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
            return false;
        } else if ($("#<%=txtPlaceOfMeeting.ClientID %>").val() == "") {
            alert("Please enter place of meeting.");
            $("#<%=txtPlaceOfMeeting.ClientID %>").focus();
            $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
            return false;
        } else if ($("#<%=txtStartDate.ClientID %>").val() == "") {
            alert("Please enter start date.");
            $("#<%=txtStartDate.ClientID %>").focus();
            $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
            return false;
        } else if ($("#<%=txtEndDate.ClientID %>").val() == "") {
            alert("Please enter end date.");
            $("#<%=txtEndDate.ClientID %>").focus();
            $("#<%=btnSubmit.ClientID %>").attr("disabled", false);
            return false;
        } else {
            var parameter = {
                request_no: $("#<%=lblRequestNo.ClientID %>").text(),
                initiator_user_id: $("#<%=hInitiatorUserId.ClientID %>").val(),
                initiatingDate: $("#<%=lblRequestdate.ClientID %>").text(),
                embassy_country_id: $("#<%=ddlEmbassyCountry.ClientID %>").val(),
                embassy_address: $("#<%=txtEmbassyAddress.ClientID %>").val(),
                nationality: $("#<%=lblNationality.ClientID %>").text(),
                passport_no: $("#<%=txtPassportNo.ClientID %>").val(),
                company: $("#<%=lblCompanyName.ClientID %>").text(),
                designation: $("#<%=lblDesignation.ClientID %>").text(),
                joining_date: $("#<%=lblJoiningDate.ClientID %>").text(),
                travel_country_id: $("#<%=ddlTravelCountry.ClientID %>").val(),
                place_of_meeting: $("#<%=txtPlaceOfMeeting.ClientID %>").val(),
                travel_start_date: $("#<%=txtStartDate.ClientID %>").val(),
                travel_end_date: $("#<%=txtEndDate.ClientID %>").val(),
                letter_filename: $("#<%=lblRequestNo.ClientID %>").text() + "_business_letter",
                status: '2',
                hr_letter_type_id: $("#<%=ddlLetterType.ClientID %>").val()
            };
            $.ajax({
                type: "POST",
                url: "<%=ResolveUrl("~/HRLetterService.asmx") %>/RegisterHRLetterBusinessData",
                data: JSON.stringify(parameter),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    __doPostBack('<%=btnSubmit.ClientID.Replace("_", "$") %>', '');
                },
                error: function (msg) {
                    alert("Error in saving the request. Please contact your administrator by sending the screen shot to unify.admin@unilever.com");
                    $(this).attr("disabled", false);
                    return false;
                }
            });
        }
        }
.
.
.
.

I haven’t posted all the code as the code is fine and there is no error as such. But the only problem is at if statements. The if and else if statements get executed but the else part doesn’t get executed. What can be the problem? Could you please help me? Thanks in Advance.

  • 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-06T10:45:45+00:00Added an answer on June 6, 2026 at 10:45 am

    Your code is not wrapped in ready event callback. If your code is placed in head as is, it will fire before the html exists and will never bind to the elements it is looking for, since they aren’t there yet.

       $(function(){ // shorthand for $(document).ready(){
    
           /* html exists, run your code here*/
    
       })
    

    If this doesn’t resolve issue, use a browser console to check for errors thrown

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

Sidebar

Related Questions

I have a website using ASP.NET MVC, everything was working fine, but I'd like
am using Asp.Net C# 2.0. My website is working fine in local. Website contains
i am working on asp.net website and we are using knockout.js. I am not
I am working on ASP.NET 3.5 website project and using jQuery to warn users
I am using jquery fullcalendar and asp.net-mvc. It works fine out of the box
I'm using jquery to access a asp.net web service from my website. This web
I am creating a website using JavaScript/ASP.NET/C#/CSS/HTML/Compact SQL server. I have the majority of
I am using jQuery Autocomplete on my ASP.net page. I am not sure how
I am using JQuery mobile in asp.net web form website. I have the following
I'm fetching JSON from my ASP .NET website using the following jQuery: $.ajax({ type:

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.