Thursday, September 10, 2009

Hiding Fields From Users on Custom Form Pages

I didn't want the users to see all of the editble fields when I displayed a custom list, and on a custom NewForm, I didn't want the users to edit the variable I had just filled in with the query string (my earlier post). So, I hid them. I used two methods:
1. The CustomDispForm.aspx and for fields that weren't required, I placed the content in an asp panel with visibility set to false:
<asp:panel visible="false" runat="server">
<!-- put content here-->
I am wary of just erasing content, since SharePoint may need it to work. Plus, I wanted to easily pull it back in if I changed my mind about displaying it, so leaving it there, but making it invisible was the best option.
2. For the CustomNewForm.aspx, since the field that I wanted to hide was required and it didn't seem to like being moved to an asp panel, I just put a style on the row in the table where the item was:
<tr style="display:none">

No comments:

Post a Comment