sharepoint 2010 - Is it feasible to dynamically assign a VisualWebPart instance to a WebPart? -
i working on webpart needs morph based on current user; if 1 person, see collection of controls, person see else (based on role/the situation).
is sensible way of accomplishing create n visualwebparts, , swap out specific vwp hosted webpart based on current user? or there standard way of doing better/easier (i new sharepoint, hence don't know what's "normal").
i think there many ways dynamically change webpart's contents. 1 way accomplish in single visualwebpart have multiple sections of controls each encapsulated panel control. control visibility of panels using code create dynamic rendering.
<asp:panel id="defaultpanel" runat="server" visible="true"> <h3>default text or controls here</h3></asp:panel> <asp:panel id="specialpanel" runat="server" visible="false"> <h3>special text or controls</h3></asp:panel>
then in code
bool showspecialtextonly = (somebooleantestcondition); if (showspecialtextonly ) { defaultpanel.visible=false; specialpanel.visible=true; }
Comments
Post a Comment