Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 12, 2012 02:00 AM by shakimran
Member
3 Points
26 Posts
Dec 05, 2012 10:24 AM|LINK
I want to pass the text box value to controller .....
Grid.Column(header:"Quantities",format: @<text> <input id="quantity" oninput="javascript:return ValidateQuantities();" type="number" min="0" max="@item.Quantities"/></text>), Grid.Column(header:"Add to cart", format:@<text> <a href="@Url.Action("AddToCart", "Flowers", new { id = item.ID , amount = test })">Add</a></text>))
I came up with 1 strategy but I dont know how to do :
1. save the input id="quantity" in a variable lets say "test" and pass the variable "test" to controller when I call @Url.action
2. Later on I want to check if this variable "test" and perform a validation check with jquery. How can i get this variable in the javascript ?
<script type="text/javascript"> function ValidateQuantities() { valueQuan = $("#quantity").val(); //if(valueQuan>){ //} //return confirm("Thats too many"); } </script>
All-Star
21343 Points
1818 Posts
Microsoft
Dec 12, 2012 01:23 AM|LINK
baoh 1. save the input id="quantity" in a variable lets say "test" and pass the variable "test" to controller when I call @Url.action
The link doesn't post the value in the textbox, you can use submit button instead.
baoh How can i get this variable in the javascript ?
$(function () { $('#id_of_your_link').click(function () { var value = $('#textdata').val(); $(this).attr('href', function () { return this.href += '?param=' + encodeURIComponent(value); }); }); });
Hope this helpful Regards
330 Points
149 Posts
Dec 12, 2012 02:00 AM|LINK
hi,
try this
grid.Column("Edit", format: @<text><a href="javascript:SubmitValues('@item.Col1','@item.Col2','@item.Col3');">Edit</a></text>, header: "Edit")
<script>
function SubmitValues(value1, value2, value3)
{
//Function body
}
</script>
baoh
Member
3 Points
26 Posts
How to pass the input value in a WebGrid to controller
Dec 05, 2012 10:24 AM|LINK
I want to pass the text box value to controller .....
Grid.Column(header:"Quantities",format: @<text> <input id="quantity" oninput="javascript:return ValidateQuantities();" type="number" min="0" max="@item.Quantities"/></text>), Grid.Column(header:"Add to cart", format:@<text> <a href="@Url.Action("AddToCart", "Flowers", new { id = item.ID , amount = test })">Add</a></text>))I came up with 1 strategy but I dont know how to do :
1. save the input id="quantity" in a variable lets say "test" and pass the variable "test" to controller when I call @Url.action
2. Later on I want to check if this variable "test" and perform a validation check with jquery. How can i get this variable in the javascript ?
<script type="text/javascript"> function ValidateQuantities() { valueQuan = $("#quantity").val(); //if(valueQuan>){ //} //return confirm("Thats too many"); } </script>Young Yang -...
All-Star
21343 Points
1818 Posts
Microsoft
Re: How to pass the input value in a WebGrid to controller
Dec 12, 2012 01:23 AM|LINK
The link doesn't post the value in the textbox, you can use submit button instead.
$(function () { $('#id_of_your_link').click(function () { var value = $('#textdata').val(); $(this).attr('href', function () { return this.href += '?param=' + encodeURIComponent(value); }); }); });Hope this helpful
Regards
Feedback to us
Develop and promote your apps in Windows Store
shakimran
Member
330 Points
149 Posts
Re: How to pass the input value in a WebGrid to controller
Dec 12, 2012 02:00 AM|LINK
hi,
try this
grid.Column("Edit", format: @<text><a href="javascript:SubmitValues('@item.Col1','@item.Col2','@item.Col3');">Edit</a></text>, header: "Edit")
<script>
function SubmitValues(value1, value2, value3)
{
//Function body
}
</script>