Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display the similar information in every view?
    primarykey
    data
    text
    <p>I would like to display the information about user's registration state. It should be displayed on every view, but i consider, that writting this code for about 20 times is a bad idea. By the way, this is the code, it works, i guarantee that:</p> <p>View/RegistrationInfo:</p> <pre><code>&lt;table width="95%" border="0" cols="2"&gt; &lt;tr&gt; &lt;td width="50%" height="124"&gt;&lt;h2&gt;&lt;strong&gt;Simple Blog &lt;/strong&gt;&lt;/h2&gt;&lt;/td&gt; &lt;td width="50%" height="124"&gt; @if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { using (Html.BeginForm("LogOff", "Account")) { &lt;table width="95%" height="86" border="0"&gt; &lt;tr&gt; &lt;td width="50%" valign="middle"&gt;Hello, @System.Web.HttpContext.Current.User.Identity.Name&lt;/td&gt; &lt;td width="50%" valign="middle" align = "right"&gt;&lt;input type="submit" value="Exit" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; } } else { using (Html.BeginForm("LogIn", "Home")) { &lt;table width="95%" height="86" border="0"&gt; &lt;tr&gt; &lt;td width="45%" valign="bottom"&gt;Login:&lt;/td&gt; &lt;td width="45%" valign="bottom"&gt;Password:&lt;/td&gt; &lt;td width="10%"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="45%"&gt; &lt;p&gt; &lt;input type="text" name="login" /&gt; &lt;/p&gt; &lt;/td&gt; &lt;td width="45%"&gt; &lt;p&gt; &lt;input type="password" name="password" /&gt; &lt;/p&gt; &lt;/td&gt; &lt;td width="10%" align="left"&gt; &lt;input type="submit" value="Enter" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="45%" valign="top"&gt; @Html.ActionLink("Register", "Register", "Account") &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; } } &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;hr align="left" width="100%" size="2" /&gt; </code></pre> <p>As you can see, this view doesn't require to be strongly typed... and i don't know, should I modify any controllers (because, all information is stored in HTML Context), and how. I tried to call</p> <pre><code>@Html.RenderAction("RegistrationInfo", "Home"); </code></pre> <p>or @Html.RenderPartial("RegistrationInfo", "Home");</p> <p>and every time i receive compile error with message about invalid parametres</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.
    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