Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 547251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:57:13+00:00 2026-05-13T10:57:13+00:00

THe variable email below is used twice: first inside the <p> tag, and then

  • 0

THe variable email below is used twice: first inside the <p> tag, and then is passed as a value of a textbox.

Question: Will both occurencies yield the same text? Believe it or not – they are different.

#UserProfileEditForm form = (UserProfileEditForm)ViewData["form"];
#string email = form.email;
<p>Email: ${HttpUtility.HtmlEncode(email)} <a class="ajax edit" href="${editEmailUrl}">Edit</a></p>
#if (form.editEmail)
#{
    <form name="f_email" action="${editEmailUrl}" ....>
        ${Html.TextBox("form.email", email, new { @class="ajax string"}) }
    </form>
#}
</div>

When I submit the above form to the server and intentionally type a malformed email address, the form will bounce back to me with an error message (omited here for clarity). The email value will appear twice in the HTML – all in line with the above code. The only problem is that the email value inside the <p> tag will be different from what’s in the text box. A sample output is below:

<p>Email: test@testing.test <a class="ajax edit" href="...">Edit</a></p>
    <form class="ajax edititem" name="f_email" id="f_email" .....>
        <input class="ajax string" id="form_email" type="text" value="changed````@testing.gov" />
    </form>
</div>

How does this happen? How can the same variable, used twice in the code, assigned only once, deliver two different values???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:57:13+00:00Added an answer on May 13, 2026 at 10:57 am

    Html.TextBox uses the previous value of the field, if available from the ModelState (this is preserved by MVC internals during request). Clear ModelState (completely or for this field) to force “email” variable value to be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl variable $results that gets returned from a service. The value
emailBody.Replace("[CONFIRMATION_LINK]", confirmLink); // now that the emailBody variable is set, send the email emailer.sendEmail(emailAddress,
I have an email sign up and search box that have the label inside
Static variable gotcha in php I am from Java background and have switched to
If I have a variable in C# that needs to be checked to determine
Is there a .NET variable that returns the All Users directory?
I have a variable of type Dynamic and I know for sure one of
As far as variable naming conventions go, should iterators be named i or something
How can I unset variable? For example, PHP has an unset($var) function.
The __debug__ variable is handy in part because it affects every module. If I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.