Link to home
Start Free TrialLog in
Avatar of dizzycat
dizzycat

asked on

MVC pass a string between views

Hi Guys

I am quite new to MVC and I am developing a little application for the purposes of learning, the problem I have is in my application I want to pass a string from a textbox in one view to a label in another  view, what is the best way to do this, I have thought of storing the string in a model or storing the string as a variable in a controller.  I am using MVC 4 and C#. Hope somebody out there has an example of how to do this.
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Could you clarify a little what you are trying to achieve?

What you are describing could equate to one of several things:

a) copying from a textbox to a label in current view (which could be done with client-side script)
b) post a value to the controller, and redisplay the same view with the value in a label
c) post a value to the controller, redirect to a different action that then presents a view with the submitted value
d) none of the above
Avatar of dizzycat
dizzycat

ASKER

Sorry for not making it clearer, I think i am trying to do:

c) post a value to the controller, redirect to a different action that then presents a view with the submitted value

What i want to do in my application is for the user to type in a movie title in a textbox and then click a button in one view, and then display all comments on that movie in a label in another view.
Sorry I mean display the Movie title in a label in another view
SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Carl, that's excellent.
No problem. Hope it answered your question.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That works and is easier to understand, thanks again Carl.