Home Using bind(prefix) with TextBoxFor
Reply: 0

Using bind(prefix) with TextBoxFor

SCFi
1#
SCFi Published in 2017-12-07 14:31:13Z

I was wondering if there was anyway to use Bind along with the Html For methods. i.e.

public ActionResult SearchBar([Bind(Prefix = "Foo")]string LookupKey) { ... }

    public class Person 
    {
        string LookupKey { get; set;}
        string FirstName {get; set;}
        string LastName {get; set;}
    }

And having @Html.TextBoxFor(x=> x.LookupKey ) produce

<input type="text" name="Foo"/>

As to the why do this it is more of just pondering at the moment and may not be the way to go for proper/best practices.

Also I am not looking to override the Name propery as in @Html.TextBoxFor(x=> x.ID, new { Name ="Foo"}) I was wondering if I was missing a possible dataannotation or another method that could make this implicit for all uses. Aim of this is obfuscation of key properties

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.328336 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO