locked
How do you set TextBox.Text programmatically in MVC? RRS feed

  • Question

  • This is why I didn't want to make the switch to MVC; the most basic things I know how to do in Web Forms I do not know how to do or if it is even possible in MVC.

    I have a view that normally accepts a double value, but there is a situation where I need to switch the text to N/A.

    In the model all I can do is set the double value to 0, but I would like to know how to set the value to text if the value doesn't apply.

    @Html.DevExpress().SpinEditFor(m => m.Default.SSTempAmbient, settings => { settings.Enabled = ViewBag.Completed;

    // if it is currently Enabled if (settings.Enabled) { // if the entire collection is all Unrestrained if ((ViewBag.AllUnrestrained != null) && (ViewBag.AllUnrestrained)) { // set the value for Enabled to false settings.Enabled = false; } else { // set the value for Enabled to false settings.Enabled = true; } }

    MVC is very unnatural to me, I would like to set the value of the textbox.Text myself in code, apparently with MVC this not possible?

    How do I set the text to N/A if the value for ViewBag.AllUnrestrained is true?

    I feel like I went back to square one by working on an MVC project.

    Thank you,

    • Moved by CoolDadTx Tuesday, November 24, 2015 8:10 PM Wrong forums
    Tuesday, November 24, 2015 7:52 PM

Answers

  • Please post questions related to MVC in the ASP.NET forums (http://forums.asp.net ).  Please post questions related to third party products like DevExpress in their forums.
    • Proposed as answer by Dave PatrickMVP Tuesday, November 24, 2015 8:28 PM
    • Marked as answer by Just Karl Friday, December 11, 2015 11:25 PM
    Tuesday, November 24, 2015 8:10 PM