Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MVC3 Rendering partial action returns error

I have a problem while trying to render a partial action on my layout. On the line :

@{Html.RenderAction("Login");}

i get an error "CS1501: No overload for method 'Write' takes 0 arguments". I have tried also invoking the RenderPartial directly, with the same result... Can you tell me what is wrong?

The code of my partial view:

@model SikWebRole.Models.LogOnModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('.LoginLink').click(function () {
            $('#loginForm').submit();
        });
    });
</script>
@using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { id = "loginForm" }))
{
<div class="loginBox">
    <div class="errorMsg">
        @Html.ValidationSummary(true, "Błędny login/hasło.")
    </div>
    <div class="loginHolder">
        <input type="text" class="textInput" name="UserName" value="Login" />
    </div>

    <div class="passwordHolder">
        <input type="text" class="textInput" name="Password" value="Hasło" />
    </div>
    <input name="RememberMe" style="display:none;" type="hidden" value="true"/>
    <a href="#" class="loginLink" ><span class="loginButton">Zaloguj</span></a>

    <ul><a href="#"><li class="registerLi">Zarejestruj</li></a><a href="#"><li class="RemindLi">Przypomnij hasło</li></a></ul>
</div>

}

The function used for render action:

public PartialViewResult Login()
    {
        return PartialView("LogOnForm", new SikWebRole.Models.LogOnModel());
    }

The partial view I want to render belongs to the "LogOn" method which is from the Account Controller, and the Login method is in the Picture Controller, maybe this is the reason?

I would be glad for all the answers.

Best Regards

As requested this is the code of my Layout.cshtml: http://pastebin.com/He2Rp5P4

like image 461
domderen Avatar asked Apr 22 '26 03:04

domderen


1 Answers

In your cshtml file use @Html.Partial, not @Html.RenderPartial.

like image 88
Becuzz Avatar answered Apr 24 '26 23:04

Becuzz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!