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.
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.
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.
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.
ASKER
Sorry I mean display the Movie title in a label in another view
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Carl, that's excellent.
No problem. Hope it answered your question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That works and is easier to understand, thanks again Carl.
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