Hi all,
I've inherited the following code and i was wondering if i could pick at your brains to see if there's a nicer way to do duplicate this.
Heres the html for most of our partial input views
<% if (Html.IsInputReadOnly()) { %>
<td>
Id
</td>
<td>
<%= Html.TextBox(
"Id"
, (Model == null ? null : Model.Id)
, new { @readonly = "readonly", @disabled="disabled" }
)%>
<% } elseif (Html.IsInputDisplayable() == false) { %>
<td></td>
<td></td>
<% } else { %>
<td>Id</td>
<td><%= Html.TextBox("Id")%>
<%= Html.ValidationMessage("Id", "*")%>
</td>
<%} %>
Here are my entension methods
public static bool IsInputReadOnly(this HtmlHelper helper)
{
string actionName = ActionName(helper);
// The Textbox should be read only on all pages except for the lookup page
if (actionName.ToUpper().CompareTo("EDIT") == 0)
return true;
return false;
}
public static bool IsInputDisplayable(this HtmlHelper helper)
{
string actionName = ActionName(helper);
// The Textbox should be read only on all pages except for the lookup page
if (actionName.ToUpper().CompareTo("CREATE") == 0)
return true;
return false;
}
Thanks in advance