Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmit a form with anchor (<a>) tag with some value in ASP.Net MVC using Html.BeginFrom
    primarykey
    data
    text
    <p>I am using Html.BeginFrom ... to create a from Tag and Submit request to use external login providers.</p> <p><strong>The HttpPost action in Account Controller</strong> </p> <pre><code>// // POST: /Account/ExternalLogin [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult ExternalLogin(string provider, string returnUrl) { return new ExternalLoginResult(provider, Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl })); } </code></pre> <p>I need to send the RetunUrl and the Provider to the above action method Currently i am creating Multiple forms using a <code>Foreach</code> with <code>Razor</code> </p> <pre><code>@foreach (ExternalLoginViewModel loginViewModel in Model) { using (Html.BeginForm("ExternalLogin", "Account", new { Provider = loginViewModel.AuthenticationClientData.DisplayName, ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post)) { @Html.AntiForgeryToken() &lt;a class="@loginViewModel.AnchorCssClass" style="@loginViewModel.AnchorCssStyle" href="#"&gt; &lt;div class="@loginViewModel.DivCssClass" style="@loginViewModel.DivCssStyle"&gt; &lt;span aria-hidden="true" class="@loginViewModel.IconCssClass"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/a&gt; } } </code></pre> <p>But i think it can be done using a single from but i dont know how i can provide the <code>Provider</code> value which varies with the anchorTag Something like :</p> <pre><code>using (Html.BeginForm("ExternalLogin", "Account", new { Provider = "&lt;SomeValue&gt;", ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post)) { @Html.AntiForgeryToken() @foreach (ExternalLoginViewModel loginViewModel in Model) { &lt;a class="@loginViewModel.AnchorCssClass" style="@loginViewModel.AnchorCssStyle" href="#"&gt; &lt;div class="@loginViewModel.DivCssClass" style="@loginViewModel.DivCssStyle"&gt; &lt;span aria-hidden="true" class="@loginViewModel.IconCssClass"&gt;&lt;/span&gt; &lt;/div&gt; &lt;/a&gt; } } </code></pre> <p><strong>Javascript used in the earlier case is (it works fine)</strong> </p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $(document).on("click", ".CSSclassonAnchor", function (e) { e.preventDefault(); var form = $(this).closest("form"); form.submit(); }); }); &lt;/script&gt; </code></pre> <p>I think its somehow will be posssible to post data using an anchor Tag Any help in this regard will be great.. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload