I have a code block as follows:
@foreach (System.Data.DataRow drEquipment in Model.EquipmentList.Rows)
{
<tr>
<td valign="top">@drEquipment["ColumnName"]<br /></td>
<td valign="top">@drEquipment["ColumnName"] - @drEquipment["ColumnName"]<br /></td>
<td valign="top">@drEquipment["ColumnName"]</td>
<td valign="top">@drEquipment["ColumnName"] - @drEquipment["ColumnName"]</td>
<td>@Html.ActionLink("Güncelle", "UpdateAction", new { SerialNumber = drEquipment["ColumnName"], StockSpecCd = drEquipment["ColumnName"], ResourceSpecTypeCd = drEquipment["ColumnName"] }, new { popup="{\"height\":250, \"width\":350}" })</td>
</tr>
}
@Html.ActionLink("Update", "UpdateAction", new { SerialNumber = drEquipment["ColumnName"], StockSpecCd = drEquipment["ColumnName"], ResourceSpecTypeCd = drEquipment["ColumnName"], new { popup="{\"height\":250, \"width\":350}" })
It is working well like this but I couldn't site popup center of the screen. That's why I have an onclick event as follows:
onclick="MyPopup('/Account/UpdateAction', '350', '250')"
So I couldn't use a variable like id to use e.preventDefault because there is a foreach statement.
I solve this problem on button click event and it works well:
<button onclick="MyPopup('/Account/UpdateAction', '350', '250')">Update</button>
function MyPopup(url, width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
//Open the window.
window.open(url, "_blank",
"status=no,height=" + height + ",width=" + width + ",resizable=yes,left="
+ leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY="
+ topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
}
But I couldn't use my function with Html.Actionlink. I put an onclick event as an htmlAttritube but it didn't work.
What I exactly need is pass my parameters to controller and open new _blank window "site center of the screen". I have all my needs without last one.
How do I fix this problem?
url,widthorheightproperties when you call the function. Now I've formatted your question you can also see you have a syntax error in the ActionLinkeditbutton to update the code in the question.