Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 10, 2012 09:42 AM by Mudasir.Khan
Member
92 Points
331 Posts
Jul 10, 2012 09:13 AM|LINK
hi all
i'm very newbie of mvc application,i have small doubts in this
1. i have to validate the attachement size is below 2 MB and file extension like .txt and .doc file only(have to validate while attaching)
2. how to validate my text area text length shouldn't more than 300 letters.(if user type more than 300 letters i have to raise error)
i dont know where to write the validation also.
please help me out..
All-Star
15346 Points
3142 Posts
Jul 10, 2012 09:42 AM|LINK
1)
if (FileUpload1.PostedFile.ContentLength > 0)
{
//ContentLength returns the size in bytes
}
if(FileUpload1.PostedFile.FileName.EndsWith(".txt") || FileUpload1.PostedFile.FileName.EndsWith(".doc"))
2) if(txtContet.Text.Length()>300)
//display error message
selvakumars
Member
92 Points
331 Posts
Attachement Size verification
Jul 10, 2012 09:13 AM|LINK
hi all
i'm very newbie of mvc application,i have small doubts in this
1. i have to validate the attachement size is below 2 MB and file extension like .txt and .doc file only(have to validate while attaching)
2. how to validate my text area text length shouldn't more than 300 letters.(if user type more than 300 letters i have to raise error)
i dont know where to write the validation also.
please help me out..
Mudasir.Khan
All-Star
15346 Points
3142 Posts
Re: Attachement Size verification
Jul 10, 2012 09:42 AM|LINK
1)
if (FileUpload1.PostedFile.ContentLength > 0){if(FileUpload1.PostedFile.FileName.EndsWith(".txt") || FileUpload1.PostedFile.FileName.EndsWith(".doc")){{