Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a control in my ASPX file and a button to do postback:

<SharePoint:FormField ID="MyID" runat="server" FieldName="Title" ControlMode="Edit"/>
<asp:Button ID="MyButton" runat="server" Text="Postback" OnClick="Button_Clicked"/>

In my code-behind I want to change ControlMode of MyID control on postback. But it doesn't work. I do this change using simple piece of code.

 MyID.ControlMode=SPControlMode.Display;

However, for some reasons it changes appearance only after the second postback.

I tried to use debugger and could see that ControlMode of my control changes immediately as expected and I could see that it equals "Display" on SaveViewState and RenderControl events, but anyway I could see my control in Edit mode in the browser.

I ran out of ideas and could not understand what can I do for further investigation. Possibly when I add control through ASPX page I should change it in some special lifecycle event.

Could you help me in my investigation, please. Every suggestions are very appreciated.

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.