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

  • Home
  • SEARCH
  • 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 6617509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:42:47+00:00 2026-05-25T20:42:47+00:00

I have been facing an issue to display Message Box after executing of some

  • 0

I have been facing an issue to display “Message Box” after executing of some code in controller

for ex:-

public ActionResult IsLoginExsit(CustomerDO loginData)
        {

            JsonResult jsonResult = new JsonResult();            
             if (!string.IsNullOrEmpty(loginData.UserName) && !string.IsNullOrEmpty(loginData.Password))                 
             {                     
                 bool result = Businesss.Factory.BusinessFactory.GetRegistrations().IsLoginExist(loginData.UserName, loginData.Password);                     

                     jsonResult.Data = result;

             }      
             return jsonResult;
        }

as seen in above example, if result is true or false, then i would like to display message box stating that login is suceess or fail.

<!-- language: lang-.html -->
    <form class="formStyle" action="#" method="POST" id="frmAuthenticate">
            <div class="row">
            <input class="text row" type="text" value="" id="txtUserName"/>
            </div>
            <div class="row">
            <input class="text row" type="password" value="" id="txtPassword" /> 
            </div>  
            <div class="row last">
            <a class="link" href="">Forgot Password?</a>   
            <a class="button3" href="/Registration/Registration" title="Registration" >Signup</a>        
<input type="submit" class="button4" id="btnGo" value="Go" />            
            </div>
        </form>

If login is exist i want to navigate to “/Customer/CollaborationPortal”, else i would like to display message “Authroization fail”.

$("#btnGo").click(function (e) {
                var RegData = getRegData();
                if (RegData === null) {
                    console.log("Specify Data!");
                    return;
                }
 var json = JSON.stringify(RegData)
                $.ajax({
                    url: '/Registration/IsLoginExsit',
                    type: 'POST',
                    dataType: 'json',
                    data: json,
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {                     
                    if(data.result == true){                                                 
                    location.href = "/Customer/CollaborationPortal";                     
                    }                    
                     else{
                         alert("Login failed"); //or whatever                     
                     }             
                     }
                });
return false;
            });
            function getRegData() {

                var UserName = $("#txtUserName").val();
                var Password = $("#txtPassword").val();
                return { "UserName": UserName, "Password": Password };
            }

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-05-25T20:42:48+00:00Added an answer on May 25, 2026 at 8:42 pm

    There is no way do that in MVC as simple as in winforms application.

    Simplest way to display message box on web page in your case is to change this action from ActionResult to JsonResult, and replace your if with:

    return Json(new {result = result});
    

    and, in web page you need to use ajax (i.e. submit a form using jquery’s $.post) and in callback function check for result:

    $("form input[type=submit]").click(function(){
        var formData = $(this).closest("form").serialize();
        $.post("urltoyourcontrollerhere/IsLoginExsit", formData, function(data){
            if(data && data.result == true){ alert("Login exists!");}
        });
    });
    

    UPDATE
    The code you posted seems OK, but there is one problem. The success function:

    success: function (data) {
                            location.href = "/Customer/CollaborationPortal";
                        }
    

    This function will always perform redirect, no matter what controller has returned. You need to check if data.result (if you returned your json as Json(new {result = result});) is true, and then redirect, else display alert. So, try:

    success: function (data) {
                        if(data.result == true){                        
                            location.href = "/Customer/CollaborationPortal";
                        }
                        else{
                            alert("Login failed"); //or whatever
                        }
                }
    

    Another thing:

                var RegData = getRegData();
                if (RegData === null)
    

    If you want this to work, you need to return null from getRegData when one of textboxes is empty.

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

Sidebar

Related Questions

I have been facing a weird issue in a piece of code. void app_ErrDesc(char
I have been facing issue with sphinx result set for string attribute. Below is
Hell All, So I have been facing this behavior for quite some time and
I have been facing this issue with my application and do not know what
Been Facing this issue,I Have as my view <%= form_for(:pin, :url => {:action =>fees})
I have been facing an issue. I implemented push notification in iOS with custom
We have been facing Out of Memory errors in our App server for sometime.
Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
I have been tasked with refactoring some components that used xmlbeans to now make
I have been facing a scenario where I have observed that Android's TelephonyManager is

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.