Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
I was trying to find a simple appliation in MVC3 which does not have to do anything with entity framework.
all I need is one page(view) with one text box and one button. we should be able to enter some text in textbox and upon pressing button the text should got to model where a simple function can make it upper case and return string.

then this uppercsed text deisplayed on same view(page) or another page.
so a simple applicaiton where one can see how View Controller and Model talk to each other. that is all thanks.
Posted
Updated 11-Oct-12 16:56pm
v2
Comments
[no name] 11-Oct-12 22:56pm    
Uh huh.... and? You just want someone to whip out a code solution for you just for the fun of it? Did you plan on paying someone to perform this work for you? Did you read the posting guidelines, that were right in front of you while posting your "question", that instructed you not to ask for code?

1) Install MVC3 on your development machine.
2) Open Visual Studio 2010
3) Create a new Project -> Visual C# -> Web -> ASP.NET MVC 3 Web Application
4) Hit OK
5) Voila, you have a fully functional MVC3 Application that doesn't use Entity Framework.
6) Create a textbox on you Home/Index view and provide the appropriate Controller method.
7) Ask a question about the code where you fail that we will be willing to answer.
 
Share this answer
 
v2
First of all my apologies for asking a question which looks like a request for a code, however it was not my original intention. May be I have not choose my words carefully. All I wanted was a way to pass information between views, controller and models without Entity FrameWork. Please note my first language is not English that may cause the confusion.
I have been doing some research so I will explain what I learn, for those who may have same issues and would come to this page.
There are following ways to get values from view back to controller after submitting the form. lets assume I have a text box in my form(View) named "txtBox" and I want to pass whatever user types in, back to controller.

1. FormCollection object
FormCollection is builtin object, which will give you access to all controls of the form.
C#
public ActionResult Index (FormCollection col) {
string str = col["txtBox"];
}


2. Request object
C#
public ActionResult Index () {
string str = Request["txtBox"];
}


3. I can't name it but it is a simple parameter passing. please note that name of parameter should be same as name of control(in this case txtBox). you can have multiple parameters depending upon number of controls you want to access. I agree not a very pretty way, but it works.
C#
public ActionResult Index (string txtBox) {
string str = txtBox;
}


and ofcourse we have the option to tie your view to Model and then pass that model object back to controller.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900