.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

validation control

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net

hi everyone,

i have an issue about validations on form. for example i have a controller for file upload.

public class FileController : Controller
        // GET: /File/

        public ActionResult Index()
            return View();

        public ActionResult Upload()

              //first step control file size  and if size >50mb write on page "size >>50"

              //second step....                  show warning



i writed steps well but how can write warnings on page?

View Complete Post

More Related Resource Links

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Validation Control Query



I've read that if you put a validation control on a page it performs the validation on the client AND server side.

My question is, if you've got a button's click event and you put code in there that puts submitted data into a database, how will the validation controls stop the data being inserted?

Is validation simply performed before anything else, then the page just stops?

Validation control half disapears in CollapsibelPanel

Hi all,I have a textbox sitting at the bottom of a collapsible panel which has a  RequiredFieldValidator sitting underneath that. If a user tries to submit the form without filling in this textbox then the RequiredFieldValidator generates a little "Required" box beneath the textbox.The trouble is that the panel doesn't resize propely and only the top of the validation warning box is visible so the message isn't legible.I tried adding some margin-bottom to the div that contains the textbox and validator to ensure the space was already there but the moment the validation box appears the collapsible panel automatically resizes so the bottom of the panel meets the bottom of the textbox, ignoring the prior margin.Apart from moving the validation box, does anyone know how I can get the collapsible panel to resize correctly?ThanksVanlightly

How to make cause validation false for Show Edit buttons in Gridview control

  HI. I am having 2 (dept name, City)dropdownlist, 1 Save button once if we click the save then record will be displayed in grid (Gridview with ShowEditbutton =true and I have Edit logic in my page). But if I click on Edit button then if I try to update the value then it is firing a message "Select dept" because dept dropdown present in the page so I want to make cause validation false for Show Edit buttons (update and cancel). Pleaase tell me Thanks

validation control increase page size

Hi all,In my web page I have lot of validation controls. These controls emit some script block to the page, that increase my page size Is there any way to put that script in to separate js fileneed client validation also.

Validation control

Hi   I have problem with validation control:For Salary I have Numeric(16,4) in database, but when I am entering "1111111111111" from my web page means more than 12 digit then it is giving me error, because of after saving this value in database will be "1111111111111.0000" that is out of range.I want to do validation but this regular expression is not working.Please give me correct validationexpression pleaseThanksSwapnil <table class="SmallTable"> <tr> <td>    <asp:TextBox ID="txtMonthlyPension" runat="server" CssClass="input" MaxLength="16" Style="text-align: right" TabIndex="8"></asp:TextBox> </td>

User Control Validation is not working properly

In my Website I have header control (header.ascx) and footer control (footer.ascx)In header.ascx one textbox and one button is there. Textbox meant for accepting search string.In footer.ascx one textbox and one button is there. Textbox meant for accepting Email-Id.Now in validation of header.ascx I had done blank checking by JavaScript. And in validation of footer.ascx  I had done blank-checking and e-mail checking by javascript.In both the control the textbox and the button both resides under Panel control whose DefaultButton property set to the respective button ids. So that if User write write something and press ENTER key from keyboard then it should do whatever respective Button_Clicks will do.Now My problem is suppose I place the mouse cursor in footer.ascx's textbox and press the ENTER key it validates properly but after that if I place the cursor inheader.ascx's textbox and press the ENTER then it is not working. Again If I do the opposite then also first one will fire but in case of second it is not firing .......

Adding New Error Message to Validation Summary Control



 In the code behind based on a condition i want to add a error message to the Validation Control.

 I tried the below.

 'Call function to add error message.
protected void AddErrorToValidationSummary(string errorMessage)
 CustomValidator custVal = new CustomValidator();   
 custVal.IsValid = false;   
 custVal.ErrorMessage = errorMessage;  
 custVal.EnableClientScript = false;   
 custVal.Display = ValidatorDisplay.None;        



Server control validation


Hi there,

I am writing a server control and I am looking for a way to inform the developer that one of the parameters that she passed to the server control is missing or is wrong.

How do I do that ?

Control Validation



VS2010/VB/ASP.NET 4.0

Have a dropdownlist control which I am populating with Items.Add("CountryStringHere")  and would like to validate the control

Of course I can use the SelectedIndex property but I'd prefer to use a field validator control

In the Regular Expression Validator there is an initial value but have no reason to check to see if anyone has entered valid text as such but has chosen something than ListIndex zero

How would I go about using one of the validation controls to do this without using the basic If statement like follows:

If DropDownList1.SelectedIndex > 0 Then

   ' Do Nothing


   ' Select a country from the list

End If

The Initial Value will be "-Country Select-" ' Index 0

Thanks in advance for your suggestions

wizard control validation


 I'm using a wizard control and on step 1 I need to do some valdiation prior to the user going to the next step. I have a JS file that I'm using on other web forms (not using the wizard), and I want to use that file as well.


How can I call that js file to do my validation of my form using the wizard?

also, I have 2 checkboxes on my form in the wizard control step 1, and 1 has to be checked, what is the best way to validate that prior to the user going to step 2?



Set focus on erronous control on validation inside ajax tabcontrol having 5 tab


Hiii.. Everybody

How to set the focus on textbox when requiredfield validator error mesage comes to action inside the ajax tabcontrol.The ajax tabcontrol is having 5 tabs.The submit button is in 5th tab .I have reqiredfield validator for textbox  in 1st tab.I want to set the focus on textbox if validation fails.Is it possible to get without postback????

Is there anyone can help me out ????

Thanks in advance

server side validation to file upload control in asp.net



how to validate a file upload control to allow  maximum "100kB" Size images.if exceed it should fire a asp validation"file size must be 100KB maximum".


Many Thanks in Advance. 

validation control in datalist error


hi guys,

i'm having some problem with my validation control that i put inside my datalist template. the purpose of the validation is to ensure that user enter only integer at the textbox inside the datalist. however, if there is more that 1 record/row at the datalist and i enter the integer only in one of the textbox at a specific row, the validation control ask me to enter a value for the other datalist record when i press the button. so my question is, is there a way to make sure that the validation control only check the specific textbox at the specific row?? i tried editing the properties of the validation control but i cannot find anything that is relevant...

Your help is greatly appreciated!!

Thank you in advance


Java script validation vs Tab control



I want to add tab control in existing asp.net page. The problem is to when I add it the controls used in tab panel get prefix at runtime and all the validations get errors(Java script validations). I know only one way to solve this problem; that was add the prefix(actually tab control name with some symbols) to every control accessing places. But this is very difficult because my page has more than 200 control (using java script) and it is difficult to change every control depending on tab control. Is there any easy way to do this?


why doesn't validation control stop application?


I use a validation control to check if value entered is numeric.  When I type letter in the textbox, the error messages shows for a second, then the application continues, and eventually throw exception. 

I'm going to add server side validation in code behind.  But I wonder why the validation control doesn't stop the application.  I don't see any difference between this web form and other web forms where validation controls work fine.

Could somebody tell me what may be the cause?  I'll appreciate your help!

Validation for Ajax Combobox control


for Ajax Combobox controls validation is not working.

Please help me out with quick solution 


Thank you




ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend