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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:46:27+00:00 2026-05-23T20:46:27+00:00

I may be missing something obvious here, but how could I rewrite this code!

  • 0

I may be missing something obvious here, but how could I rewrite this code!

i am trying here to store the value entered in the textbox(Textbox was showed in javascript dialog page).In a javascript dialog page i have one ‘ok’ button.. when i click the button i want to store the value entered in the textbox.I want to save the content using Ajax.

Please see my sample code
View page:

<script language="javascript" type="text/javascript">
    $(function () {
        $('.button').live('click', function () {
            $('.Text_dialog').dialog('open');
        });

        $('.Text_dialog').dialog({
            autoOpen: false,
            buttons: {
                'Ok': function () {
                    var textValue = $(':txtValue').val();
                    $.ajax({
                        url: '/Home/About',
                        type: 'POST',
                        data: { str: textValue },
                        success: function (result) {
                            alert(result.val);
                        }
                    });
                },
            }
        });
    });

</script>


     <input type="button" value="Add Value" class="button" />
     <div class="Text_dialog" title="Basic modal dialog">
          TextValue: <input type="text" class="txtValue" />
</div>

Control page:

[HttpPost]
    public ActionResult About(string str)
    {
        ValidateClass ObjAM = new ValidateClass();
        int value = ObjAM.ValidatetextValue(str);
        return Json(new { val = value });
    }

Model page:

 public class ValidateClass
    {
        DataClasses1DataContext dbObj = new DataClasses1DataContext();
        public int ValidatetextValue(string str)
        {
            string value = (from SearchtextValue in dbObj.Options
                                where SearchtextValue.OptionName == str
                                select SearchtextValue.OptionName).Single();
            if (value == null)
            {
                return 1;
            }
            return 0;

        }
    }

When i run this code i am getting script error like “Object doesn’t support this property or method”.Please advice

  • 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-23T20:46:29+00:00Added an answer on May 23, 2026 at 8:46 pm

    Change data: { str: textValue } to data: "{ 'str' :'" + textValue +"' }"

    If you are confused on escaping the quotes properly, try this.

    $(function() {
        $('.button').live('click', function() {
            $('.Text_dialog').dialog('open');
        });
    
        $('.Text_dialog').dialog({
            autoOpen: false,
            buttons: {
                'Ok': function() {
                    var DTO = "{ 'str' :'" + $('.txtValue').val() +"' }";
                    $.ajax({
                        url: '/Home/About',
                        type: 'POST',
                        data: DTO,
                        success: function(result) {
                            alert(result.val);
                        }
                    });
                },
            }
        });
    });
    

    Please note that I have changed the :txtValue to .txtValue as it is the correct selector.

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

Sidebar

Related Questions

I may be missing something obvious here, but how could I rewrite this code
I may be missing something obvious here, but in the devel module settings I
I may just be missing something obvious here, so I apologize if this is
I may be missing something here because I thought this might be really easy
Noob who may be missing something obvious ... I'm trying to debug an Rspec
I may be missing something obvious about this in the documentation for addKeyListener ,
I'm writing my first expect script, so I may be missing something obvious, but
I'm may be missing something but I can't find the Delphi 2007 WSDL Importer
I'm relatively new to Django and OO, so I may be missing something obvious,
This may be a basic question, but I could not find an answer for

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.