ASP .Net MVC simple task2019 Community Moderator ElectionWhat are MVP and MVC and what is the difference?Sending email in .NET through GmailHow do you create a dropdownlist from an enum in ASP.NET MVC?What is the difference between MVC and MVVM?.NET - JSON serialization of enum as stringMVC pattern on AndroidFile Upload ASP.NET MVC 3.0my javascript code not working(debugger not going inside get method)I cant get this form to send email or redirect to the correct viewSetting a column default value in the kendo ui grid to DateTime.Now

PTIJ: Who should I vote for? (21st Knesset Edition)

Is a party consisting of only a bard, a cleric, and a warlock functional long-term?

What did “the good wine” (τὸν καλὸν οἶνον) mean in John 2:10?

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?

Official degrees of earth’s rotation per day

Why do passenger jet manufacturers design their planes with stall prevention systems?

How to terminate ping <dest> &

Why does overlay work only on the first tcolorbox?

Are ETF trackers fundamentally better than individual stocks?

Math equation in non italic font

How can we have a quark condensate without a quark potential?

What options are left, if Britain cannot decide?

Could the Saturn V actually have launched astronauts around Venus?

et qui - how do you really understand that kind of phraseology?

Is there a place to find the pricing for things not mentioned in the PHB? (non-magical)

Is "upgrade" the right word to use in this context?

Why Choose Less Effective Armour Types?

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

Why is a white electrical wire connected to 2 black wires?

Different outputs for `w`, `who`, `whoami` and `id`

Knife as defense against stray dogs

How to pronounce "I ♥ Huckabees"?

Is there a hypothetical scenario that would make Earth uninhabitable for humans, but not for (the majority of) other animals?

Could this Scherzo by Beethoven be considered to be a fugue?



ASP .Net MVC simple task



2019 Community Moderator ElectionWhat are MVP and MVC and what is the difference?Sending email in .NET through GmailHow do you create a dropdownlist from an enum in ASP.NET MVC?What is the difference between MVC and MVVM?.NET - JSON serialization of enum as stringMVC pattern on AndroidFile Upload ASP.NET MVC 3.0my javascript code not working(debugger not going inside get method)I cant get this form to send email or redirect to the correct viewSetting a column default value in the kendo ui grid to DateTime.Now










0















I have a problem with one task: When user go on main page see form to enter number and button'Answer'

After when user give number and push button the user receives information:



  • "Yes" if number is even

  • "No" if number is uneven

That is a Index.cshtml






@model WebApplication10.Models.PersonModel

@
Layout = null;


<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))

<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" align="center">Give number</th>
</tr>
<tr>

<td>
@Html.TextBoxFor(m => m.Number)
</td>
</tr>

<tr>
<td></td>
<td><input type="submit" value="Answer" /></td>
</tr>
</table>

</body>
</html>





This is my PersonModel.cs






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication10.Models

public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;









and HomeController






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication10.Models;

namespace WebApplication10.Controllers

public class HomeController : Controller

// GET: Home
public ActionResult Index()

return View();

[ HttpPost]
public ActionResult Index(PersonModel person)

return View(person);











I am beginner in ASP .Net MVC and really and I don't how make this, I made a button bu I do not know where and how I should do a function which will check a number>>










share|improve this question
























  • idownvotedbecau.se/noattempt

    – Dani
    Mar 7 at 15:41











  • Have you tried anything? Got any code?

    – JamesS
    Mar 7 at 15:46











  • I edited my post,I tried but this didn't work

    – Krystek
    Mar 7 at 16:04















0















I have a problem with one task: When user go on main page see form to enter number and button'Answer'

After when user give number and push button the user receives information:



  • "Yes" if number is even

  • "No" if number is uneven

That is a Index.cshtml






@model WebApplication10.Models.PersonModel

@
Layout = null;


<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))

<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" align="center">Give number</th>
</tr>
<tr>

<td>
@Html.TextBoxFor(m => m.Number)
</td>
</tr>

<tr>
<td></td>
<td><input type="submit" value="Answer" /></td>
</tr>
</table>

</body>
</html>





This is my PersonModel.cs






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication10.Models

public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;









and HomeController






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication10.Models;

namespace WebApplication10.Controllers

public class HomeController : Controller

// GET: Home
public ActionResult Index()

return View();

[ HttpPost]
public ActionResult Index(PersonModel person)

return View(person);











I am beginner in ASP .Net MVC and really and I don't how make this, I made a button bu I do not know where and how I should do a function which will check a number>>










share|improve this question
























  • idownvotedbecau.se/noattempt

    – Dani
    Mar 7 at 15:41











  • Have you tried anything? Got any code?

    – JamesS
    Mar 7 at 15:46











  • I edited my post,I tried but this didn't work

    – Krystek
    Mar 7 at 16:04













0












0








0








I have a problem with one task: When user go on main page see form to enter number and button'Answer'

After when user give number and push button the user receives information:



  • "Yes" if number is even

  • "No" if number is uneven

That is a Index.cshtml






@model WebApplication10.Models.PersonModel

@
Layout = null;


<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))

<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" align="center">Give number</th>
</tr>
<tr>

<td>
@Html.TextBoxFor(m => m.Number)
</td>
</tr>

<tr>
<td></td>
<td><input type="submit" value="Answer" /></td>
</tr>
</table>

</body>
</html>





This is my PersonModel.cs






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication10.Models

public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;









and HomeController






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication10.Models;

namespace WebApplication10.Controllers

public class HomeController : Controller

// GET: Home
public ActionResult Index()

return View();

[ HttpPost]
public ActionResult Index(PersonModel person)

return View(person);











I am beginner in ASP .Net MVC and really and I don't how make this, I made a button bu I do not know where and how I should do a function which will check a number>>










share|improve this question
















I have a problem with one task: When user go on main page see form to enter number and button'Answer'

After when user give number and push button the user receives information:



  • "Yes" if number is even

  • "No" if number is uneven

That is a Index.cshtml






@model WebApplication10.Models.PersonModel

@
Layout = null;


<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))

<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" align="center">Give number</th>
</tr>
<tr>

<td>
@Html.TextBoxFor(m => m.Number)
</td>
</tr>

<tr>
<td></td>
<td><input type="submit" value="Answer" /></td>
</tr>
</table>

</body>
</html>





This is my PersonModel.cs






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication10.Models

public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;









and HomeController






using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication10.Models;

namespace WebApplication10.Controllers

public class HomeController : Controller

// GET: Home
public ActionResult Index()

return View();

[ HttpPost]
public ActionResult Index(PersonModel person)

return View(person);











I am beginner in ASP .Net MVC and really and I don't how make this, I made a button bu I do not know where and how I should do a function which will check a number>>






@model WebApplication10.Models.PersonModel

@
Layout = null;


<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))

<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" align="center">Give number</th>
</tr>
<tr>

<td>
@Html.TextBoxFor(m => m.Number)
</td>
</tr>

<tr>
<td></td>
<td><input type="submit" value="Answer" /></td>
</tr>
</table>

</body>
</html>





@model WebApplication10.Models.PersonModel

@
Layout = null;


<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))

<table cellpadding="0" cellspacing="0">
<tr>
<th colspan="2" align="center">Give number</th>
</tr>
<tr>

<td>
@Html.TextBoxFor(m => m.Number)
</td>
</tr>

<tr>
<td></td>
<td><input type="submit" value="Answer" /></td>
</tr>
</table>

</body>
</html>





using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication10.Models

public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;









using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebApplication10.Models

public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;









using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication10.Models;

namespace WebApplication10.Controllers

public class HomeController : Controller

// GET: Home
public ActionResult Index()

return View();

[ HttpPost]
public ActionResult Index(PersonModel person)

return View(person);











using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication10.Models;

namespace WebApplication10.Controllers

public class HomeController : Controller

// GET: Home
public ActionResult Index()

return View();

[ HttpPost]
public ActionResult Index(PersonModel person)

return View(person);












c# asp.net model-view-controller






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 16:23









Tiw

4,11761630




4,11761630










asked Mar 7 at 15:40









KrystekKrystek

12




12












  • idownvotedbecau.se/noattempt

    – Dani
    Mar 7 at 15:41











  • Have you tried anything? Got any code?

    – JamesS
    Mar 7 at 15:46











  • I edited my post,I tried but this didn't work

    – Krystek
    Mar 7 at 16:04

















  • idownvotedbecau.se/noattempt

    – Dani
    Mar 7 at 15:41











  • Have you tried anything? Got any code?

    – JamesS
    Mar 7 at 15:46











  • I edited my post,I tried but this didn't work

    – Krystek
    Mar 7 at 16:04
















idownvotedbecau.se/noattempt

– Dani
Mar 7 at 15:41





idownvotedbecau.se/noattempt

– Dani
Mar 7 at 15:41













Have you tried anything? Got any code?

– JamesS
Mar 7 at 15:46





Have you tried anything? Got any code?

– JamesS
Mar 7 at 15:46













I edited my post,I tried but this didn't work

– Krystek
Mar 7 at 16:04





I edited my post,I tried but this didn't work

– Krystek
Mar 7 at 16:04












1 Answer
1






active

oldest

votes


















0














Idk if this is exactly what you want but I added;



 <td>
@Html.TextBoxFor(m => m.Number)
@Html.DisplayFor(m => m.IsEven)
</td>


and



 public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;
public string IsEven get return Number % 2 == 0 ? "Even" : "Odd";








share|improve this answer























  • ok,thanks very much,it works but I have one more question :how to make that after I give number new page is open and then I see a statement ?

    – Krystek
    Mar 7 at 17:08











  • So your return view is returning the page based on its name so its looking for index. So you can either change that or do return View("ViewName",person);

    – Ryan Schlueter
    Mar 7 at 17:22











  • so in Controller I edited this: public ActionResult Index(PersonModel person) return View("ViewName", person); but this didn't work

    – Krystek
    Mar 7 at 17:37












  • ViewName is the view you are wanting it to go to. The new page. So Results or EvenNumberResults whatever the new view you created you want it to go to.

    – Ryan Schlueter
    Mar 7 at 17:40











  • OK,Now I understood,one more question ,Can I check the value of number in Controller rather than in Model?

    – Krystek
    Mar 7 at 18:11










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047622%2fasp-net-mvc-simple-task%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Idk if this is exactly what you want but I added;



 <td>
@Html.TextBoxFor(m => m.Number)
@Html.DisplayFor(m => m.IsEven)
</td>


and



 public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;
public string IsEven get return Number % 2 == 0 ? "Even" : "Odd";








share|improve this answer























  • ok,thanks very much,it works but I have one more question :how to make that after I give number new page is open and then I see a statement ?

    – Krystek
    Mar 7 at 17:08











  • So your return view is returning the page based on its name so its looking for index. So you can either change that or do return View("ViewName",person);

    – Ryan Schlueter
    Mar 7 at 17:22











  • so in Controller I edited this: public ActionResult Index(PersonModel person) return View("ViewName", person); but this didn't work

    – Krystek
    Mar 7 at 17:37












  • ViewName is the view you are wanting it to go to. The new page. So Results or EvenNumberResults whatever the new view you created you want it to go to.

    – Ryan Schlueter
    Mar 7 at 17:40











  • OK,Now I understood,one more question ,Can I check the value of number in Controller rather than in Model?

    – Krystek
    Mar 7 at 18:11















0














Idk if this is exactly what you want but I added;



 <td>
@Html.TextBoxFor(m => m.Number)
@Html.DisplayFor(m => m.IsEven)
</td>


and



 public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;
public string IsEven get return Number % 2 == 0 ? "Even" : "Odd";








share|improve this answer























  • ok,thanks very much,it works but I have one more question :how to make that after I give number new page is open and then I see a statement ?

    – Krystek
    Mar 7 at 17:08











  • So your return view is returning the page based on its name so its looking for index. So you can either change that or do return View("ViewName",person);

    – Ryan Schlueter
    Mar 7 at 17:22











  • so in Controller I edited this: public ActionResult Index(PersonModel person) return View("ViewName", person); but this didn't work

    – Krystek
    Mar 7 at 17:37












  • ViewName is the view you are wanting it to go to. The new page. So Results or EvenNumberResults whatever the new view you created you want it to go to.

    – Ryan Schlueter
    Mar 7 at 17:40











  • OK,Now I understood,one more question ,Can I check the value of number in Controller rather than in Model?

    – Krystek
    Mar 7 at 18:11













0












0








0







Idk if this is exactly what you want but I added;



 <td>
@Html.TextBoxFor(m => m.Number)
@Html.DisplayFor(m => m.IsEven)
</td>


and



 public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;
public string IsEven get return Number % 2 == 0 ? "Even" : "Odd";








share|improve this answer













Idk if this is exactly what you want but I added;



 <td>
@Html.TextBoxFor(m => m.Number)
@Html.DisplayFor(m => m.IsEven)
</td>


and



 public class PersonModel


///<summary>
/// Gets or sets PersonId.
///</summary>
public int Number get; set;
public string IsEven get return Number % 2 == 0 ? "Even" : "Odd";









share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 7 at 16:16









Ryan SchlueterRyan Schlueter

2,0472919




2,0472919












  • ok,thanks very much,it works but I have one more question :how to make that after I give number new page is open and then I see a statement ?

    – Krystek
    Mar 7 at 17:08











  • So your return view is returning the page based on its name so its looking for index. So you can either change that or do return View("ViewName",person);

    – Ryan Schlueter
    Mar 7 at 17:22











  • so in Controller I edited this: public ActionResult Index(PersonModel person) return View("ViewName", person); but this didn't work

    – Krystek
    Mar 7 at 17:37












  • ViewName is the view you are wanting it to go to. The new page. So Results or EvenNumberResults whatever the new view you created you want it to go to.

    – Ryan Schlueter
    Mar 7 at 17:40











  • OK,Now I understood,one more question ,Can I check the value of number in Controller rather than in Model?

    – Krystek
    Mar 7 at 18:11

















  • ok,thanks very much,it works but I have one more question :how to make that after I give number new page is open and then I see a statement ?

    – Krystek
    Mar 7 at 17:08











  • So your return view is returning the page based on its name so its looking for index. So you can either change that or do return View("ViewName",person);

    – Ryan Schlueter
    Mar 7 at 17:22











  • so in Controller I edited this: public ActionResult Index(PersonModel person) return View("ViewName", person); but this didn't work

    – Krystek
    Mar 7 at 17:37












  • ViewName is the view you are wanting it to go to. The new page. So Results or EvenNumberResults whatever the new view you created you want it to go to.

    – Ryan Schlueter
    Mar 7 at 17:40











  • OK,Now I understood,one more question ,Can I check the value of number in Controller rather than in Model?

    – Krystek
    Mar 7 at 18:11
















ok,thanks very much,it works but I have one more question :how to make that after I give number new page is open and then I see a statement ?

– Krystek
Mar 7 at 17:08





ok,thanks very much,it works but I have one more question :how to make that after I give number new page is open and then I see a statement ?

– Krystek
Mar 7 at 17:08













So your return view is returning the page based on its name so its looking for index. So you can either change that or do return View("ViewName",person);

– Ryan Schlueter
Mar 7 at 17:22





So your return view is returning the page based on its name so its looking for index. So you can either change that or do return View("ViewName",person);

– Ryan Schlueter
Mar 7 at 17:22













so in Controller I edited this: public ActionResult Index(PersonModel person) return View("ViewName", person); but this didn't work

– Krystek
Mar 7 at 17:37






so in Controller I edited this: public ActionResult Index(PersonModel person) return View("ViewName", person); but this didn't work

– Krystek
Mar 7 at 17:37














ViewName is the view you are wanting it to go to. The new page. So Results or EvenNumberResults whatever the new view you created you want it to go to.

– Ryan Schlueter
Mar 7 at 17:40





ViewName is the view you are wanting it to go to. The new page. So Results or EvenNumberResults whatever the new view you created you want it to go to.

– Ryan Schlueter
Mar 7 at 17:40













OK,Now I understood,one more question ,Can I check the value of number in Controller rather than in Model?

– Krystek
Mar 7 at 18:11





OK,Now I understood,one more question ,Can I check the value of number in Controller rather than in Model?

– Krystek
Mar 7 at 18:11



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047622%2fasp-net-mvc-simple-task%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme