how to pass parameter from @Url.Action to controller function

后端 未结 10 789
一生所求
一生所求 2020-12-02 19:42

I have a function CreatePerson(int id) , I want to pass id from @Url.Action.

Below is the reference code:

pub         


        
10条回答
  •  自闭症患者
    2020-12-02 20:22

    public ActionResult CreatePerson (string id)
    
    window.location.href = '@Url.Action("CreatePerson", "Person" , new {id = "ID"})'.replace("ID",id);
    
    public ActionResult CreatePerson (int id)
    
    window.location.href = '@Url.Action("CreatePerson", "Person" , new {id = "ID"})'.replace("ID", parseInt(id));
    

提交回复
热议问题