I want to add hidden field to every view i have through jquery or javascript. But i want that code to be in MasterPage.Master so i write code at one place and it adds on every view i have. Can i do this if yes then how? Im using asp.net mvc 2
In your master:
$(function() {
$('body').append(
$('<input/>')
.attr('type', 'hidden')
.attr('name', 'foo')
.val('some value')
);
});
or replace $('body')
with some other selector to a placeholder you've put somewhere in your master page if you want this hidden field to be inserted in some specific position. You could also insert it into existing <form>
by giving them some id or class (if you have more of them on the same page and you wanted to insert this hidden field in each form).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With