[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 82
  • Last Modified:

Getting class set textbox value?

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
sbornstein2
Asked:
sbornstein2
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
Can you show the code for how you are making the ajax call, and setting the control with the result?
0
 
sbornstein2Author Commented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now