Dotnet Core button redirect with parameters
up vote
0
down vote
favorite
I'm making a Web API application that populates data into a datagrid. Currently, I'm wanting to have a button that will call my webapi endpoint with an additional parameter.
My datagrid, and the button code is below. This is the entirety of my razor page code:
@(Html.DevExtreme().DataGrid<Batch>().ID("gridContainer")
.Columns(columns =>
{
columns.Add().CellTemplate(
@<text>
@(Html.DevExtreme().Button()
.ID("sendButton")
.Text("Select Batch")
.OnClick("function () { onItemClick(data); }"))
</text>);
columns.AddFor(m => m.BatchId).Caption("BatchId");
columns.AddFor(m => m.CobId).Caption("Cob Id");
})
.DataSource(d => d.WebApi().Controller("Batches").LoadAction("GetAllEntries").Key("BatchId"))
)
<script>
var idValue;
function onItemClick(data)
{
DevExpress.ui.notify(data.Id);
console.log(data.BatchId);
idValue = data.BatchId;
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = idValue })';
}
</script>
In my script the variable idValue
contains the value I want to pass into my URL, yet when I try to place it in the Url.Action it tells me that it doesn't exist in the current context
What is the best way to pass idValue
into my redirect action?
javascript c# .net-core
add a comment |
up vote
0
down vote
favorite
I'm making a Web API application that populates data into a datagrid. Currently, I'm wanting to have a button that will call my webapi endpoint with an additional parameter.
My datagrid, and the button code is below. This is the entirety of my razor page code:
@(Html.DevExtreme().DataGrid<Batch>().ID("gridContainer")
.Columns(columns =>
{
columns.Add().CellTemplate(
@<text>
@(Html.DevExtreme().Button()
.ID("sendButton")
.Text("Select Batch")
.OnClick("function () { onItemClick(data); }"))
</text>);
columns.AddFor(m => m.BatchId).Caption("BatchId");
columns.AddFor(m => m.CobId).Caption("Cob Id");
})
.DataSource(d => d.WebApi().Controller("Batches").LoadAction("GetAllEntries").Key("BatchId"))
)
<script>
var idValue;
function onItemClick(data)
{
DevExpress.ui.notify(data.Id);
console.log(data.BatchId);
idValue = data.BatchId;
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = idValue })';
}
</script>
In my script the variable idValue
contains the value I want to pass into my URL, yet when I try to place it in the Url.Action it tells me that it doesn't exist in the current context
What is the best way to pass idValue
into my redirect action?
javascript c# .net-core
Possible duplicate of how to pass parameter from @Url.Action to controller function in asp.net mvc3
– Kirk Larkin
Nov 7 at 11:50
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm making a Web API application that populates data into a datagrid. Currently, I'm wanting to have a button that will call my webapi endpoint with an additional parameter.
My datagrid, and the button code is below. This is the entirety of my razor page code:
@(Html.DevExtreme().DataGrid<Batch>().ID("gridContainer")
.Columns(columns =>
{
columns.Add().CellTemplate(
@<text>
@(Html.DevExtreme().Button()
.ID("sendButton")
.Text("Select Batch")
.OnClick("function () { onItemClick(data); }"))
</text>);
columns.AddFor(m => m.BatchId).Caption("BatchId");
columns.AddFor(m => m.CobId).Caption("Cob Id");
})
.DataSource(d => d.WebApi().Controller("Batches").LoadAction("GetAllEntries").Key("BatchId"))
)
<script>
var idValue;
function onItemClick(data)
{
DevExpress.ui.notify(data.Id);
console.log(data.BatchId);
idValue = data.BatchId;
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = idValue })';
}
</script>
In my script the variable idValue
contains the value I want to pass into my URL, yet when I try to place it in the Url.Action it tells me that it doesn't exist in the current context
What is the best way to pass idValue
into my redirect action?
javascript c# .net-core
I'm making a Web API application that populates data into a datagrid. Currently, I'm wanting to have a button that will call my webapi endpoint with an additional parameter.
My datagrid, and the button code is below. This is the entirety of my razor page code:
@(Html.DevExtreme().DataGrid<Batch>().ID("gridContainer")
.Columns(columns =>
{
columns.Add().CellTemplate(
@<text>
@(Html.DevExtreme().Button()
.ID("sendButton")
.Text("Select Batch")
.OnClick("function () { onItemClick(data); }"))
</text>);
columns.AddFor(m => m.BatchId).Caption("BatchId");
columns.AddFor(m => m.CobId).Caption("Cob Id");
})
.DataSource(d => d.WebApi().Controller("Batches").LoadAction("GetAllEntries").Key("BatchId"))
)
<script>
var idValue;
function onItemClick(data)
{
DevExpress.ui.notify(data.Id);
console.log(data.BatchId);
idValue = data.BatchId;
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = idValue })';
}
</script>
In my script the variable idValue
contains the value I want to pass into my URL, yet when I try to place it in the Url.Action it tells me that it doesn't exist in the current context
What is the best way to pass idValue
into my redirect action?
javascript c# .net-core
javascript c# .net-core
edited Nov 7 at 11:34
asked Nov 7 at 11:14
N0xus
1,295742100
1,295742100
Possible duplicate of how to pass parameter from @Url.Action to controller function in asp.net mvc3
– Kirk Larkin
Nov 7 at 11:50
add a comment |
Possible duplicate of how to pass parameter from @Url.Action to controller function in asp.net mvc3
– Kirk Larkin
Nov 7 at 11:50
Possible duplicate of how to pass parameter from @Url.Action to controller function in asp.net mvc3
– Kirk Larkin
Nov 7 at 11:50
Possible duplicate of how to pass parameter from @Url.Action to controller function in asp.net mvc3
– Kirk Larkin
Nov 7 at 11:50
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The @Url.Action is processed at the server side. So passing a dynamic value from client side to it may not be possible. But as a work-around you can use the below code
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = "ID"})'.replace("ID",idValue );
If you like it, credit should be given to the original poster here
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The @Url.Action is processed at the server side. So passing a dynamic value from client side to it may not be possible. But as a work-around you can use the below code
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = "ID"})'.replace("ID",idValue );
If you like it, credit should be given to the original poster here
add a comment |
up vote
1
down vote
accepted
The @Url.Action is processed at the server side. So passing a dynamic value from client side to it may not be possible. But as a work-around you can use the below code
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = "ID"})'.replace("ID",idValue );
If you like it, credit should be given to the original poster here
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The @Url.Action is processed at the server side. So passing a dynamic value from client side to it may not be possible. But as a work-around you can use the below code
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = "ID"})'.replace("ID",idValue );
If you like it, credit should be given to the original poster here
The @Url.Action is processed at the server side. So passing a dynamic value from client side to it may not be possible. But as a work-around you can use the below code
window.location.href = '@Url.Action("SeanTest", "BatchDatagrid", new {@id = "ID"})'.replace("ID",idValue );
If you like it, credit should be given to the original poster here
answered Nov 7 at 11:47
Thangadurai
1,165923
1,165923
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53188380%2fdotnet-core-button-redirect-with-parameters%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of how to pass parameter from @Url.Action to controller function in asp.net mvc3
– Kirk Larkin
Nov 7 at 11:50