Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have one doubt.

I have one view called CustomerMaster. In CustomerMaster view I have field Like 'Area', 'City' etc. If city is already in the list it will be automatically shown in the Dropdown .

Suppose the City which I need is not in the list, means I have to add that city. So I decided to keep one 'Add' button near to 'city' field. If I click that button it needs to redirect to that view. So how can i do this in MVC4?

1) How can I keep button near to the field?
2) How to redirect from one view to another view while clicking the button in mvc4?

Thanks .
Posted
Updated 25-Nov-15 23:34pm
v2
Comments
John C Rayan 26-Nov-15 5:33am    
What you are trying to do is a normal process in MVC4. What's the error are you getting? If you are new to MVC4 then you have to learn some fundamentals of MVC4. Tell us what you have tried so far.
Member 12087373 26-Nov-15 5:37am    
Hi john Thanks for replying.. I kept one button near to City Field.

<input type='button' value='Dummy Button' />

But i donno how to redirect to another view while clicking this button . I need that coding or some link to refer ..
Member 12087373 26-Nov-15 6:48am    
John Its working fine . Now i have another doubt
John C Rayan 26-Nov-15 8:09am    
what is your doubt
Member 12087373 26-Nov-15 8:18am    
ya i already said . i.e How to do Update, Delete Process using Code First Approach. I complete Insert process using code first approach same as like mentioned in the below link.

http://www.codeproject.com/Tips/651495/Inserting-Data-into-Multiple-Tables-using-Code-Fir

(if u cant able to see this link means you go and see the page with title Insert data into multiple tables using " Code First approach and ViewModel" in Codeproject website.)

so I need to do Update and delete process in MVC4. My Customer form is complete upto insert process. Still need to do update and delete process .. How to do that using Code first approach .This is my doubt?

You can try one of the following approch
As mentioned by Sanjay create an action link like this
HTML
@Html.ActionLink("Button name", "ActionName", "ControllerName") 

There should be a controller with name ControllerName and an action method like below
C#
public ActionResult ActionName()
{
   return View();
}


Or you can try like this:
HTML
<input type='button' value='Dummy Button' id='myButton' onClick='redirectOnClick()' />
<script>
function redirectOnClick(){
    document.location ='ControllerName/ActionName';
}
</script>
 
Share this answer
 
v3
See this article for your query

MVC4 Different Redirection Techniques (Razor)[^]
 
Share this answer
 
Comments
Member 12087373 26-Nov-15 5:42am    
ok dude. lets i have a try. suppose if i got any error means i will tell you.
John C Rayan 26-Nov-15 7:02am    
you are welcome.
Member 12087373 26-Nov-15 7:04am    
John I have one big doubt. I have "Customer Master". Customer Master contain 22 fields. I have Db Contain Multiple tables for Customer Master. If I connect my Db with Vb express it shows each view for each table. so i tried to bring all fields in single view and tried to insert the data into multiple tables. For that I used "Code First Approach " i followed the method same as like which is mentioned in the below link. Its working Fine.

Inserting Data into Multiple Tables using Code First Approach and ViewModel[^]

Now my question is I Finished the insert process using Code first approach.. Now " how to do UPDATE process using this approach.. Because i did only the insertion process . still i need to do Update , Details, Delete.. How to do that?
John C Rayan 26-Nov-15 7:35am    
You could consider store procedure if you are worried about performance issue using EF. By the way , you link doesn't work.
Member 12087373 26-Nov-15 7:49am    
oh store procedure . i use Store Procedure for Update Process or for performance problem john ?
Hi,
Try Below Code


You can pass your action and controller name

HTML
@Html.ActionLink("Home", "ActionName", "ControllerName")
 
Share this answer
 
v2
Comments
Member 12087373 26-Nov-15 5:41am    
Thanks for your reply dude..ok i have a check..

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