[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

ASP.Net MVC 4 C# -- textbox blank after click

Posted on 2013-06-11
3
Medium Priority
?
658 Views
Last Modified: 2013-07-11
How can I get the below "Desired Steps" working in ASP.Net MVC 4 C# ?
---------------------------------------------------------
Current Steps
 1. edit POdetailController.cs
      ** change below Edit method
           podetail.ApprovedDate = DateTime.Now;
           return View(podetail);
 2. user logs into APP, clicks Edit
 3. APPROVED textbox automatically displays today's date
 4. user manually removes date if they do NOT approve
---------------------------------------------------------
Desired Steps
 1. user logs into APP, clicks Edit
 2. APPROVED textbox automatically displays BLANK
 3. user clicks inside APPROVED textbox
 4. today's date appears
 5. user clicks inside APPROVED textbox again
 6. today's date gets removed
0
Comment
Question by:finance_teacher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
Craig Wagner earned 2000 total points
ID: 39246266
Seems like it would make the most sense to handle this client-side.

<input id="approved" type="text" onclick="toggle()" />

<script>
    function toggle() {
        var box = document.getElementById("approved");

        if (box.value === "") {
            box.value = new Date();
        }
        else {
            box.value = "";
        }
    }
</script>

Open in new window

0
 

Author Comment

by:finance_teacher
ID: 39276009
Below works, but allows users to enter their own text next to the automatic date text.

This is a box they click into when they are done approving an item, I don't want to allow users to type additional text.

How can I setup so users CANNOT enter their own text, they can only save the SYSTEM generated TEXT that happens after they click ?

Other option would be to change from a textbox to an "Approved" checkbox and then write logged in user/today'sDate to database.
------------------------------------------------------------------------------------------------------------
            @Html.TextBoxFor(model => model.LastModifiedBy, new { @onclick = "toggle()" })
------------------------------------
    <script>
        function toggle() {
            var box = document.getElementById("LastModifiedBy");

            if (box.value === "") {
                box.value = new Date();
            }
            else {
                box.value = "";
            }
        }
</script>
0
 
LVL 21

Expert Comment

by:Craig Wagner
ID: 39276139
Have you tried disabling the textbox? I'm not sure if that would kill the response to the click event but it's worth a try.
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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

649 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