views:

141

answers:

3

Hello,

I am trying to populate a couple text box fields in my MVC application. I have a text box that a user can enter an ID and then click search, and based on the ID input from the user, information should be brought back to populate First Name, Last Name text boxes on the same page.

The problem I am having is bringing back this data from a SQL Stored Procedure and displaying the results on the same page in different text boxes. I just can't seem to figure out how to bring that information back to the same page instead of having to show a different view.

Any advice or solutions would be greatly appreciated.

Thanks.

A: 
"how to bring that information back to the same page"

call the Action over the same controller.

For displaying data in Textboxes, fetched from DataSource, use

           <%= Html.TextBox(Model.FirstName)%>               
           <br />
           <%= Html.TextBox(Model.LastName)%>
           <br />
           <%= Html.TextBox(Model.SearchResults)%>

review these Tutorials


Hope this helps

Asad Butt
Thanks for the quick reply, but how do I get that info. back to the different text boxes on the page.
GB
have edited, the links include sample application and complete tutorial
Asad Butt
A: 

You decide which View to show in the return from your Action; why do you feel forced to show a different one?

pdr
A: 

Question is really vague but at a guess, you want AJAX functionality, something like this....

$.post("/Home/Search",                      //action to post to
       { query: $('#searchBox').val() },    //data to post, ie. search box text
        function(data){                     //callback funtion to process return data  somehow.
            alert("Data Loaded: " + data);  //do what you want here
        }
 );
Paul Creasey