Solved

Getting class set textbox value?

Posted on 2015-02-04
3
70 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article discusses how to create an extensible mechanism for linked drop downs.
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)
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…

772 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