Solved

Getting class set textbox value?

Posted on 2015-02-04
3
78 Views
Last Modified: 2015-02-10
Hello all,

I have some code that I use to set a read only textbox value such as this:

@Html.TextBoxFor(model => model.OriginalValue, new { @class = "setOrigVal k-textbox", @disabled = "true", style = "width: 110px; background-color:#eee" })

When this happens in an ajax post I can properly set the value to the control that shows on the UI in the textbox:
 $(".setOrigVal").val(resp.OriginalValue);

Problem is when I go to get the value its showing "".   How can I handle this to get the value set?

This is what I am doing:
var tbOrigValue = $(".setOrigVal").val();

but its "".
0
Comment
Question by:sbornstein2
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 40588882
Can you show the code for how you are making the ajax call, and setting the control with the result?
0
 

Author Comment

by:sbornstein2
ID: 40588993
Sure thing:

Here it is:

 function getOriginalValue() {
        debugger;
        var dsDropDownLst = $("#DataSourceDropDown").data("kendoDropDownList");
        var dtMarketValue = $("#MVDate").data("kendoDatePicker");

        if (dsDropDownLst.value() > 0 && dtMarketValue.value() != null) {
            var url = '@Url.Action("GetPortfolioOrigMarketValue", "Portfolio")';

            var dataVals = {};
            dataVals["id"] = "@Model.PortfolioID";
            dataVals["dsid"] = dsDropDownLst.value();
            dataVals["mvdate"] = dtMarketValue.value();

            $.ajax({
                type: "POST",
                url: url,
                data: JSON.stringify(dataVals),
                cache: false,
                contentType: 'application/json; charset=utf-8',
                success: function (resp) {
                    $(".setOrigVal").val(resp.OriginalValue);
                },
                dataType: 'json',
            });
        } else {
            $(".setOrigVal").val("");
        }

        calcVariance();
    }

Open in new window

0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 40590599
Two things.

1) Can you post the Action that your ajax is calling, so i can see how you are formatting the response?
2) Is it definitely calling the action? I notice the else clause in your script is explicitly setting the value to blank.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
email validation 9 51
Jquery Bold 3 specific words in a paragraph 5 28
Put POST values into cookies. 14 35
JQuery on multiple lines 3 18
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question