You must Sign In to post a response.
Category: ASP.Net MVC
#768823
You use a ViewModel class to transfer the data, see below snippet
Your action method then comes out
for more details check out below link
http://stackoverflow.com/questions/4816869/mvc-pass-parameter-to-view
Thanks
Koolprasd2003
Editor, DotNetSpider MVM
Microsoft MVP 2014 [ASP.NET/IIS]
public class IndexViewModel
{
public string MainNav { get; set; }
public string SubNav { get; set; }
public IndexViewModel(string mainnav, string subnav)
{
this.MainNav = mainnav;
this.SubNav = subnav;
}
}
Your action method then comes out
public ActionResult Index(string mainnav, string subnav)
{
return View(new IndexViewModel(mainnav, subnav));
}
for more details check out below link
http://stackoverflow.com/questions/4816869/mvc-pass-parameter-to-view
Thanks
Koolprasd2003
Editor, DotNetSpider MVM
Microsoft MVP 2014 [ASP.NET/IIS]
#768861
You can use this code snippet as example for How to pass a variable in view in Controller
<a href="<?php echo base_url().'user/user_message';?>">
<button type="submit" class="btn btn-info btn-small" title="Send Message" >Send
Message</button>
</a>
<input type="hidden" name="username" value="<?php echo $username; ?>"/>
#768871
Hai Sachin,
You can use the public Property where you can set the values and then whenever you need just retrieve it. By this way, you will not loose the values which were set in the properties.
Hope it will be helpful to you.
Regards,
Pawan Awasthi(DNS MVM)
+91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
pawansoftit@gmail.com
You can use the public Property where you can set the values and then whenever you need just retrieve it. By this way, you will not loose the values which were set in the properties.
Hope it will be helpful to you.
Regards,
Pawan Awasthi(DNS MVM)
+91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
pawansoftit@gmail.com
Return to Return to Discussion Forum