Tenho uma tela com algumas informações carregadas do BD e um Formulário.
Nesse formulário, eu posso adicionar um Usuário (por UserName ou Email) que serão verificados no Active Directory.
Quando eu clico no botão adicionar que chama a função "btnSendUser_OnClick", ele deve tornar uma tabela que estava oculta em Visible = true e acrescentar lá o Nome e o Email do usuário inserido. Eu posso fazer essa inserção N vezes e a tabela deve
acrescentar uma linha automaticamente, com as mesmas informações.
Para o primeiro usuário esta Ok. Como faço para acrescentar os demais?
Meu HTML.
<asp:Label ID="lblUserAdd" runat="server" Font-Bold="true" Text="Add User - (Email or User Name)"></asp:Label>
<br />
<asp:TextBox ID="txtUserAdd" runat="server" Height="17px" Width="150px"></asp:TextBox>
<asp:Label ID="lblError" runat="server" class="control-label" for="inputError" Visible="false">Input with error</asp:Label>
<asp:Button ID="btnAddUser" class="btn" runat="server" Font-Bold="true" Text="Add User"
OnClick="btnSendUser_OnClick" />
<br />
<br />
<table id="tblUsers" class="table table-bordered table-striped" runat="server" visible="false">
<tbody>
<tr>
<td>
<asp:Label ID="lblUser" runat="server" Visible="false"></asp:Label>
</td>
<td>
<asp:Label ID="lblEmail" runat="server" Visible="false"></asp:Label>
</td>
</tr>
</tbody>
</table>
meu .cs
protected void btnSendUser_OnClick(object sender, EventArgs e)
{
string LoginInfo = txtUserAdd.Text;
PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, "x.com", "amsuser", "xxx");
UserPrincipal insUserPrincipal = UserPrincipal.FindByIdentity(insPrincipalContext, LoginInfo);
if (insUserPrincipal == null)
{
lblError.Visible = true;
}
else
{
tblUsers.Visible = true;
lblUser.Visible = true;
lblEmail.Visible = true;
lblUser.Text = insUserPrincipal.GivenName + " " + insUserPrincipal.Surname;
lblEmail.Text = insUserPrincipal.EmailAddress;
}
}
Caio Vinicius. caio89@gmail.com