0
votes

In my aspx page I have BeginForm() which contains a table T1 and i also have an Iframe I1 which is not included in Begin Form(). The problem that i m facing i have condition to check based on which i need to disable the table T1 and enable the Ifram I1. For this, i m using the Page Load () function which helps me check the condition but i m unable to access the Table T1 and hence cant set its visible value to false. i dont mind adding javascript.

The code : <% using (Html.BeginForm()) {

%>
<table id="HomePage">
    <td>......

</table>

<%   for (int i = ViewData.Model.Count - 1; i >= 0; i--)
     { %>
<div style="display: none;" id="hiddenView">
    <% Html.RenderPartial("PartiealView",object); %>
</div>
<% } %>
protected void Page_Load(object sender, Eventargs e) { if (a == b) { enable Iframe I1 and disable table t1 } else { enable Table T1 n disable Iframe 1 } }
2

2 Answers

1
votes

If you add the: runat="server" attribute to your table and iframe elements you will have access to them in your code, they will be exposed as HtmlControl objects, which have a Visible property for you. (See: http://msdn.microsoft.com/en-us/library/khc6t495(v=VS.90).aspx)

1
votes

Wrap an if-block around the items you wish to test:

<% if (...) { %>
    <table>
        ...
    </table>
<% } else { %>
    <iframe ...>
    </iframe>
<% } %>