Solved

Getting class set textbox value?

Posted on 2015-02-04
3
72 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
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 invoke it on a web page. 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.: (CODE)

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now