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

  • SEARCH
  • Home
  • 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 6646693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:26:52+00:00 2026-05-26T00:26:52+00:00

Forgive me if this seems like a simple task, I’m fairly new to this…

  • 0

Forgive me if this seems like a simple task, I’m fairly new to this…

I’d like to create logic that allows the user to display or not display their email address when editing it from a dialog box. I am placing the link that will allow the user to ‘opt out’ inside the dialog box – and I’m trying to use the link to reset the variable inside the ‘if’ statement to ‘false’ The ‘if’ statement prevents the email address from being rendered.

Here is my if statement:

<div id="change-email" class="text"> 
    @{

        var showEmail = true;

        if (showEmail == true)
        {
            <text><p><span class="label">My email address: </span>@Model.Email</p></text>
        }
        else (showEmail == false)
        {
            <text><p>No email displayed</p></text>
        }

    }
</div><!--#change-email--> 

And here is the dialog box code:

<div id="dialog-email" class="modal">

    @using (Html.BeginForm("ChangeEmail", "Account", FormMethod.Post))
    {
        <fieldset>
           // form code here
        </fieldset>
    }

    <p><a href="" class="no-display">Do not display my email address.</a></p>

</div>

Any help would be appreciated…

Thanks!

  • 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-26T00:26:52+00:00Added an answer on May 26, 2026 at 12:26 am

    If you do this with jQuery, and you were okay with the email address still being available in the page source, it would look like this:

    <div id="change-email" class="text"> 
        <p><span class="label">My email address: </span>@Model.Email</p>
    </div>
    <div id="dialog-email" class="modal">
    
        @using (Html.BeginForm("ChangeEmail", "Account", FormMethod.Post))
        {
            <fieldset>
               // form code here
            </fieldset>
        }
    
        <p><a href="" class="no-display">Do not display my email address.</a></p>
    
    </div>
    <script type="text/javascript">
    $(document).ready(function(){
        $('a.no-display').click(function(){
             $('#change-email p').text('No email displayed.');
        });
    });
    </script>
    

    It would be a bit more involved if you wanted to persist the preference to not display email. You would probably want to add “Do not display my email address” as a check-box in the ChangeEmail form, adjust the Controller Action to which the form posts to handle the preference, and return it as a variable in the ViewBag of the View that the Action returns.

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

Sidebar

Related Questions

I'm new to web design, so please forgive if this is super simple- I've
Forgive me if this seems like common sense as I am still learning how
I am definitely new to Perl, and please forgive me if this seem like
I'm a novice when it comes to sql so forgive me if this seems
I'm new to js/jQuery. Forgive this horrible script. I'm lost. *(Updated with global variable
I hope you guys forgive me ... I know this is simple but its
(The title is admittedly not that great. Please forgive my English, this is the
I've always struggled with RegEx so forgive me if this may seem like an
I have a IBAction that looks like this: self.title = @Logging in ...; [MyClass
I'm fairly new at event driven programming and using MVC so forgive me if

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.