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 7924047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:31:38+00:00 2026-06-03T17:31:38+00:00

how can i do, for example, i create a user in users.cshtml view, that

  • 0

how can i do, for example, i create a user in users.cshtml view, that it validates to ActionResult Create(RegisterModel um) and if its all ok, i want to return at users.cshtml but always with one javascript alert or similar, with the value of a variable from the action. Can i do this one?

I have it this in my view..

@using (Html.BeginForm()) {
@Html.ValidationSummary(true)

<fieldset>
    <legend>Crear Usuario</legend>

     <div class="editor-label">
        Username:
    </div>
    <div class="editor-field">
        @Html.TextBoxFor(model => model.UserName)
        @Html.ValidationMessageFor(model => model.UserName)
    </div>

    <div class="editor-label">
        Password:
    </div>
    <div class="editor-field">
        @Html.PasswordFor(model => model.Password)
        @Html.ValidationMessageFor(model => model.Password)
    </div>

            <div class="editor-label">
        Repite Password:
    </div>
    <div class="editor-field">
        @Html.PasswordFor(model => model.ConfirmPassword)
        @Html.ValidationMessageFor(model => model.ConfirmPassword)
    </div>
    </div>
    <p>
        <input type="submit" value="Crear" />
    </p>
</fieldset>

And this in my controller action..

public ActionResult Create(RegisterModel um)
{

    if (um.Password == um.ConfirmPassword)
    {
        // Attempt to register the user
        MembershipCreateStatus createStatus;
        Membership.CreateUser(um.UserName, um.Password, um.Email, um.PasswordAnswer, um.PasswordQuestion, true, null, out createStatus);

        if (createStatus == MembershipCreateStatus.Success)
        {
            var alert = MembershipCreateStatus.Success.ToString();
        }
        else
        {
            ModelState.AddModelError("", ErrorCodeToString(createStatus));

            var alert = ErrorCodeToString(createStatus);
        }
    }
        //HERE IS WHERE I WANT TO RETURN TO /ADMIN/USERS BUT WITH AN ALERT WITH CONTAINING THE VALUE OF alert IN A JAVASCRIPT OR SIMILAR ALERT WINDOW

    return RedirectToAction("Users", "Admin"); ???????

Can i do it something like this?

  • 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-06-03T17:31:42+00:00Added an answer on June 3, 2026 at 5:31 pm

    You could store the message inside TempData just before redirecting to the Users action:

    TempData["message"] = "some message that you want to display";
    return RedirectToAction("Users", "Admin");
    

    and then inside the Users.cshtml view (which is returned by the Users action to which you redirected) test for the presence of this message and display an alert:

    @if (TempData["message"] != null) {
        <script type="text/javascript">
            alert(@Html.Raw(Json.Encode(TempData["message"])));
        </script>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I create a user control like the Textbox? For example when I
I want to create a simple menu function which can call it example get_menu()
How can I create a basic UIButton programmatically? For example in my view controller,
How can I create View on Linked Server db. For Example I have a
Currently, I have URLs that look like this: http://www.example.com/user/create http://www.example.com/user/edit/1 But now, I have
I'm working on this project that an admin user can create some User's Groups
In the following example i can create an object dynamically via a string; however,
For example DbVisualizer can be used to connect to a DB and create nice
Can you give me some links or example programs to create UIButtons on a
How can I create pdf documents with 2D barcodes (for example QR code http://en.wikipedia.org/wiki/QR_Code

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.