locked
How to validate people picker control during postback RRS feed

  • Question

  • I have a custom people picker control in my custom newform.aspx.


    I am using this code

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="PIPTrackerUserControl.ascx.cs"
        Inherits="PIPTrackerUserControl" EnableViewState="true" Debug="true" %>
    <%@ Register TagPrefix="Sharepoint" Namespace="Microsoft.SharePoint.WebControls"
        Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

    <table>
            <tr>
            <td class="ms-toolbar" nowrap="nowrap" colspan="2">
                <Sharepoint:FormToolBar EnableViewState="true" Visible="true" ID="FormToolBar1" runat="server"
                    ControlMode="New" />
            </td>
        </tr>
    <tr>
    <td style="width: 350px; font-family: Verdana; font-size: 11px;" class="ms-formbody">
                <Sharepoint:PeopleEditor ID="peProposalSubmitter" AllowEmpty="true" ValidatorEnabled="true"
                    MultiSelect="false" runat="server" SelectionSet="User" Width='350px' />
    </td>
    </tr>
    <tr>       
            </td>
            <td style="font-family: Verdana; font-size: 11px;" align="right">
                &nbsp;&nbsp;&nbsp;&nbsp;<asp:Button ID="btnOK1" Text="OK" runat="server" Width="75px"
                    CssClass="ms-toolbar" OnClick="btnOK1_Click" />
             </td>
     </tr>


    ValidatorEnabled is set true.But people picker does not work during postback(that is when i click OK, the item gets added to the list even if the user entered is wrong).
    Monday, December 7, 2009 5:37 AM

Answers

  • Thanks for your reply. I already got the solution. I had to use IsValid property.Now its working fine. 
    • Proposed as answer by N L V Tuesday, December 8, 2009 7:08 AM
    • Marked as answer by Mike Walsh FIN Tuesday, December 8, 2009 7:38 AM
    Tuesday, December 8, 2009 6:54 AM

All replies

  • Can you show the code behind for the button...
    Monday, December 7, 2009 12:58 PM
  • Thanks for your reply. I already got the solution. I had to use IsValid property.Now its working fine. 
    • Proposed as answer by N L V Tuesday, December 8, 2009 7:08 AM
    • Marked as answer by Mike Walsh FIN Tuesday, December 8, 2009 7:38 AM
    Tuesday, December 8, 2009 6:54 AM