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
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>>
c# asp.net model-view-controller
add a comment |
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>>
c# asp.net model-view-controller
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
add a comment |
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>>
c# asp.net model-view-controller
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
c# asp.net model-view-controller
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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";
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
|
show 4 more comments
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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";
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
|
show 4 more comments
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";
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
|
show 4 more comments
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";
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";
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
|
show 4 more comments
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
|
show 4 more comments
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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