ASP .Net MVC simple task The Next CEO of Stack OverflowWhat 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

Why don't programming languages automatically manage the synchronous/asynchronous problem?

What can we do to stop prior company from asking us questions?

If a black hole is created from light, can this black hole then move at speed of light?

Do I need to enable Dev Hub in my PROD Org?

Won the lottery - how do I keep the money?

Multiple labels for a single equation

What does "Its cash flow is deeply negative" mean?

WOW air has ceased operation, can I get my tickets refunded?

Make solar eclipses exceedingly rare, but still have new moons

Can you replace a racial trait cantrip when leveling up?

What's the best way to handle refactoring a big file?

What connection does MS Office have to Netscape Navigator?

Should I tutor a student who I know has cheated on their homework?

To not tell, not take, and not want

Can we say or write : "No, it'sn't"?

How to count occurrences of text in a file?

What is "(CFMCC)" on an ILS approach chart?

Inappropriate reference requests from Journal reviewers

Preparing Indesign booklet with .psd graphics for print

"In the right combination" vs "with the right combination"?

Is it professional to write unrelated content in an almost-empty email?

Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?

Why do we use the plural of movies in this phrase "We went to the movies last night."?

In excess I'm lethal



ASP .Net MVC simple task



The Next CEO of Stack OverflowWhat 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,32361630




4,32361630










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,0572919




2,0572919












  • 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

1928 у кіно

Захаров Федір Захарович

Ель Греко