28.01.2015 Views

Introducere in ASP.NET Controale Web Pagina in ... - Profs.info.uaic.ro

Introducere in ASP.NET Controale Web Pagina in ... - Profs.info.uaic.ro

Introducere in ASP.NET Controale Web Pagina in ... - Profs.info.uaic.ro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<st<strong>ro</strong>ng>ASP</st<strong>ro</strong>ng>.<st<strong>ro</strong>ng>NET</st<strong>ro</strong>ng> 03.03.2014 28/30<br />

Cont<strong>ro</strong>lul CustomValidator<br />

Pe partea de client<br />

<br />

function EmpIDClientValidate(ctl, args)<br />

{<br />

// the value is a multiple of 5 if the modulus by 5 is 0<br />

args.IsValid=(args.Value%5 == 0);<br />

}<br />

<br />

Pe partea de server, eveniment CustomValidator.ServerValidate:<br />

p<strong>ro</strong>tected void EmpIDServerValidate(object sender,<br />

ServerValidateEventArgs args)<br />

{<br />

try<br />

{<br />

args.IsValid = (<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng>t.Parse(args.Value)%5 == 0);<br />

}<br />

catch<br />

{<br />

// An er<strong>ro</strong>r is most likely caused by non-numeric data.<br />

args.IsValid = false;<br />

}<br />

}<br />

Pag<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng>a .aspx<br />

<br />

*<br />

<br />

Cont<strong>ro</strong>lul ValidationSummary<br />

Nu executa actiuni de validare ci prez<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng>ta un rezumat al e<strong>ro</strong>rilor aparute <st<strong>ro</strong>ng>in</st<strong>ro</strong>ng> p<strong>ro</strong>cesul de<br />

validare.<br />

Daca p<strong>ro</strong>prietatea ShowMessageBox = true rezumatul e<strong>ro</strong>rilor este afisat pe partea de client<br />

<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng>tr-o caseta de dialog JavaScript sau pe pag<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng>a daca ShowSummary = true, atentie mai<br />

trebuie setata p<strong>ro</strong>prietatea DisplayMode <st<strong>ro</strong>ng>in</st<strong>ro</strong>ng> acest d<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng> urma caz.<br />

DisplyMode = {S<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng>gleParagraph, List, BulletList}.<br />

<br />

Ioan Asim<st<strong>ro</strong>ng>in</st<strong>ro</strong>ng>oaei

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!