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

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

AsyncFileUpload and form validation question

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

This is my first time using the AsyncFileUpload so please tell me if I'm missing something obvious.  I have it working in the sense that one can upload a file and I can save it to the correct place and all that stuff.

The implementation I am using it on is a form that sends an email, one that may or may not have an attachment.  The attachment isn't a required field, but other form fields are in fact required.

If one goes to the bottom of the form and uploads a file, without doing anything else, the file gets saved in my attachments folder on the web server.  However, it doesn't logically make sense to me that one should be able to do that without first filling out a valid form. It seems like what this is going to promote is a lot of files hanging around from those who already uploaded a file but didn't bother to fill out the rest of the form correctly.

There is an OnClientUploadStarted event, but that's too late.  It seems like there should be an OnClientBeforeUpload so form validation can take place prior to a file getting physically saved on the server.  Am I missing something?

So I guess what I could do is do server side form validation in the OnUploadedComplete event before calling the controls SaveAs method, is that really the only way to do it?  Where is the file "uploaded" to

View Complete Post

More Related Resource Links

C++ at Work: Form Validation with Regular Expressions in MFC


I thought I'd use this month's column to describe an interesting app I built using the RegexWrap library described in my article "Wrappers: Use Our ManWrap Library to Get the Best of . NET in Native C++ Code" in this issue.

Paul DiLascia

MSDN Magazine April 2005

Commerce with ASP.NET: Leverage the Authentication and Form Validation Features of ASP.NET to Bolste


If you're planning to build an e-commerce site, you'll be pleased to see that ASP.NET makes it easier than ever. Existing controls can be used and extended to add a great deal more functionality than you might expect. In this article, forms-based authentication is used to verify the identity of users and make certain areas of the site, such as the check-out page, inaccessible to unauthorized users. The power and flexibility of validation controls are demonstrated using the CustomValidator control to connect to a Web Service that verifies addresses. A shopping cart is then implemented in ASP.NET using the DataGrid, and finally, credit card authorization and billing are performed.

Jason Lefebvre and Robert Lair

MSDN Magazine August 2002

ASP.NET: Selectively Enable Form Validation When Using ASP.NET Web Controls


Sometimes the extra controls that come with Visual Studio .NET can be a bit inflexible or they just don't provide enough functionality or flexibility for all situations. The ASP.NET form validation controls, while powerful and easy to use, require that the entire page be valid before it's submitted back to the server. Through the use of the new object-oriented features of Visual Basic .NET, it is possible to extend their functionality to overcome this limitation. This article tells you how and helps you decide when it's a good idea to keep validation on the client and when you'd be better off disabling it.

James M. Venglarik II

MSDN Magazine April 2002

How to set rule only on form validation success InfoPath 2007



I'm a newbie to InfoPath 2007. I am creating a from without code. Is there a way to set a Rule to the Submit Button which will be triggered only in the case of Form validation success ? can we make use of the "Set condition" to setup a expression  in the Rule, for this purpose. Still i have no idea how to come up with an expression for such purpose. Can someone please explain.

Form validation error

When i try and submit a form..this is the error i get "The form cannot be submitted because it contains validation errors. Errors are marked with a red asterisk (required fields) or a red, dashed border (invalid values)." But i cannot see any red dotted lines and all the required fields are populated as well. When i submit my form in preview mode of Infopath: this is the error i am getting: The form contains the following errors: Field or group: Value Error: Only positive integers allowed Please help and let me know if I am missing on anything here?

.mdb and C# form question for a Rich Text Box

Ok heres my question. I have a program that i am writing that uses a .mdb database file. All the fields are set to Memo in the database for the size. My problem is i have a Rich Text Box that is used to gather info before it gets saved to the .mdb file. I narrowed it down to a maximum size problem with the RTB. Is there any way to increase the maximum data size of the RTB so that saving more then 3 sentences won't crash the program and will actually save the 3 sentences +. ?  Or is there some trick to get around that that i am not getting at the moment? So to restate my problem. I can't save anything over roughly 3 sentences from my C# form to a .mdb file without the program kicking out an exception, And the .mdb fields are already set to Memo. Thanks for any help/input in advance. This has been bugging me for a while and i haven't found anything online yet but i will keep searching.

Form Validation, BindingGroup, CommandBinding, Disabling Commit Button

Hi, I've been struggling with this for a few days and I couldn't get a clear and simple answer anywhere. Now that I've fixed the problem on my end, I figured I would share. The approach is about disabling a "Commit" button (Save/Apply/OK/whatever) whenever an error exists in the form. Basically, I have a form with several different controls (textbox, combobox, checkbox to name a few). All of them are bound to a custom object within my code, that I referenced using "RootGrid.DataContext = myObjectInstance". They also use BindingValidationRules, so the user is warned that they have wrong data in there. There's plenty of information about how to achieve this on the internet - but the real question mark is: how can I disable a button if there are errors in the form? First, go ahead and make those control validations work. For example, write a ValidationRule for a textbox to make sure it's only numbers in there, and then another ValidationRule for another textbox that ensures no digits are contained. Once again, google is full of examples on how to achieve this. Then, you need to group all of those controls into a BindingGroup. Before doing so, we will design a ValidationRule that will ensure the BindingGroup is free of validation errors:   public class ErrorFreeBindingGroup : ValidationRule { private string _errorMessage; public str

membership provider with custom login form problem / question

Hi all, I am using the .net membership provider, and I can get past the membership.validate user ok and into my secure page.   The problem I have is that when I reach the secured page, I have a login status control which isn't changing from login to logout.   Below is my login code:If Membership.ValidateUser(txtUsername.Text, txtPassword.Text) Then Response.Redirect("/auth/Default.aspx") If chkRememberMe.Checked Then FormsAuthentication.SetAuthCookie(txtUsername.Text, True) Else FormsAuthentication.SetAuthCookie(txtUsername.Text, False) End If Else lblLoginStatus.Text = "Oops! Login not found!" End If    Thanks in advance.

Validation is not working in Custom List Form using JavaScript ddwrt:GenFireServerEvent()

Hii am creating custom New form for a list using sharepoint designer. i have added the below button for sumbit<input name="Submit1" type="submit" value="Submit" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />                <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;                                    </xsl:text><input name="Submit2" type="submit" value="Cancel" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={http://myserver/Lists/VTest/AllItems.aspx}')}" />the problem is the validation is not working properly. it submits the page without entering values for the required fields.particularly the validation is not working for DateFields.let me know what is the problem here. is it a Bug?muthu

MVC Validation Pattern Question, Especially for Variable Length Lists and Conditional Validation


I've spent a lot of time exploring the various patterns of MVC validation. In particular, I am interesting in learning best-practice for validating a view which posts an enumerable collection back to the controller. One approach that is appealing involves posting the form via Ajax to check validation (http://jvance.com/blog/2010/02/20/MakingAnAjaxFormWithJQueryInASPdotNETMVC.xhtml). Obviously, the negative is that this is not true client-side validation since there is a "hidden" server round-trip, but the effect is comparable, and obviously client-side validation alone will never stand--server-side always needs to be done as well.

The CodePlex repository for this demo: http://mvcajaxvalidation.codeplex.com/SourceControl/list/changesets

The main reason I started heading this route is because in the course of writing lots of custom data annotation model validators (think "RequiredIf" or "RequiredWhenContains") it became very evident that the wiring to the client-side gets complicated. I was mostly able to pull it off using the custom validators' GetClientValidationRules() plus jQuery validator extensions (.addMethod('requiredif'...), ho

Most basic question - launch form from a hyperlink?

I created my infopath 2003 form and linked it to a forms library on MOSS. But I can't see any way to launch the form except exposing the library and having the users click the New menu item. I'd sure prefer just to have a hyperlink on a page. Is there some way to do this? The form only sends an email, it does not need to populate the library. Thanks.

Server Side Validation for SharePoint 2007 Form Fields


Hi Guys,

Need to validate NewForm.aspx and EditForm.aspx of SharePoint custom list. My current implementation is by using JavaScript. It's working fine.

Someone suggested JavaScript is not a good approach.I am unable to fetch ids dynamically by JavaScript only for few fields (people picker, calendar control) and in that case i have hard coded the ids. hardcoding is always a bad approache.

Is there any way to validate those mentioned form at server side? Is it really good way to think that my validation can put inside Event Handler?

thanksArup MCTS - SharePoint

Play Sudoku

MultiView issue with validation in form


Hi all,

Currently I am working on a user control which has the following "layout":

  • the user control elements are placed inside an Update Panel
  • inside the Update Panel I have a MultiView control with 4 views:
    • first view 2 buttons to select the type of the user to create (clicking one button changes the active view to the second view, clicking the other one activates the third view)
    • second view is for the form used to create a user type
    • third view is for the form used to create the other user type
    • forth view should be used to display the confirmation message for the creation of both user types

In both forms, besides he usual textboxes I am also using validation controls to make sure the data the user inputs is correct.

However, I have a problem in case the data is invalid (the user doesn't input some mandatory field): for a very short period of time I see the * next to the mandatory field and the error in the validation summary, but immediately the active view is switched back to the first view in the MultiView control.

How can I force the control to stay on the view with the selected form?

Any ideas, suggestions or comments are welcomed!

Thank you in advance!


Each AccordionPane with form containing controls with validation


Hey all,

I am using Accordion with multiple AccordionPane. Each AccordionPane has a form tag that contains asp controls such as dropdownlist and textboxes and buttons to submit or cancel. Each asp control has a requiredFieldValidator assign to it.  However when a i am in a particular AccordionPane to submit the form, the validator for other fields in other fields is highlighted preventing me from submitting.


Pleaseeee provide me with some assistance or light on what the problem is.  I have deadlines today.




Validation in form




I have a scenario:

If field A is no...make Field B not required. How do i do it through designer?


Thanks a lot.

A __ViewState field is being posted to my form and causing validation to fail. How do I ignore this?


I'm implementing a payment gateway, and it basically works like this:

User will do their shopping at my site, and view Cart.aspx. Cart.aspx will post the form to the payment gateway.

The payment gateway will process the payment, and then do a post back to my server at Response.ashx. It posts the details of the credit card transaction, but it will also re-post whatever I gave it. So it is giving me back a __ViewState field. (ViewState, EventValidation, RequestValidation are all disabled on both Cart.aspx, and Order.aspx, which is the page being redirected to.)

Response.ashx has the following code:

public class Response: IHttpHandler, IRequiresSessionState
public void ProcessRequest(HttpContext context)
new ResponsePresenter

public void

Sharepoint security validation error in Infopath Form


I am trying to save a  file to a sharepoint library . I am getting the data from the a infopath form

I have pasted the infopath form code below.

Adding The allowunsafeupdates=true  is not working

public void GenerateFile()




    // Write your code here.

    XPathNavigator xnDocument = this.MainDataSource.CreateNavigator();

    StringBuilder sb = new StringBuilder();

    string name = xnDocument.SelectSingleNode("/my:myFields/my:Name", NamespaceManager).Value.ToString();



    string address = xnDocument.SelectSingleNode("/my:myFields/my:Address", NamespaceManager).Value.ToString();



    string date = xnDocument.SelectSingleNode("/my:myFields/my:Date", NamespaceManager).Value.ToString();



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