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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:13:04+00:00 2026-05-23T17:13:04+00:00

I have a an actionlink in my masterlayout like this: @Html.ActionLink(Order Your Free Report

  • 0

I have a an actionlink in my masterlayout like this:

 @Html.ActionLink("Order Your Free Report 1", "CheckValue", "Product", null,new { id = "checkExists" })

I have an action method like this :

  public ActionResult CheckValue() {
            bool result = true;
            ViewData["checkCondition"] = true;
            return Json(result, JsonRequestBehavior.AllowGet);
        }

and function like this:

$(function () {
    $('#checkExists').click(function () {
     $.getJSON(this.href, function (result) {
            alert(result);
            if (result) {
                alert('the record exists');
            }           
        });
        return false;
    });
});

When I click the link, alert is not shown. But If I use like this:

 $(function () {
  $('#checkExists').click(function () {

        var condition =new Boolean('@ViewData["checkCondition"]');
        if (condition) {
            alert("message");
        }
   return false;
    });
});

It works. Please suggest why first one is not working ?

  • 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-23T17:13:05+00:00Added an answer on May 23, 2026 at 5:13 pm

    try wrapping this into $(this)

    $(function () {
        $('#checkExists').click(function () {
         $.getJSON($(this).attr('href'), function (result) {
                alert(result);
                if (result) {
                    alert('the record exists');
                }           
            });
            return false;
        });
    });
    

    the ajax version

       $(function () {
          $('#checkExists').click(function () {
    
           $.ajax({
             url: $(this).attr('href'),
             type:'GET',
             success: function (result) { ... },
             dataType: 'json',
             error:function(jqXhr,textStatus, errorThrown){
                 alert("Oops ");
                 alert(jqXhr.responseText);
                 alert(jqXhr.status);
             }
                });
              return false;
            });
        });
    

    try this and tell what alerts show up

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

Sidebar

Related Questions

I have an action link like this: <%=Html.ActionLink(Name + ( + Count+ ), ActonName,
Hi I have a question about Html.ActionLink. Imagine: @Html.ActionLink(item.title, Singlet, new { id =
I have a html.actionlink that i wish to display a link to a members
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have a ActionLink, that calls my public ActionResult, and I would like it
i have an actionlink in my view <%= Html.ActionLink(action,controller) %> the action has a
I have the following ajax.actionlink. i want to add click event to this actionlink.
i have a sentence with html. action link: <b>Please enter your username and password.
I have found this example on StackOverflow: var people = new List<Person> { new
I have an Html.ActionLink on my page and I am using the following CSS

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.