Z5 Concepts

ASP.NET C#.NET - Using CausesValidation


by on 13. September 2010 23:03

    In ASP.NET, when using the RequiredFieldValidator control on a textbox, you must always enter a value in the textbox before postback occurs. In the event you have a form which has a textbox that cannot be null or must have a value, you want to use the ASP.NET RequiredFieldValidator control.

    On most forms, you typically have a submit button. You also should have either a cancel button, or a reset button of some sort to either refresh the page, or clear the form fields. If this is the case, and you have a requiredfieldvalidator control tied to one of your textbox controls, then whenever the textbox is empty, and a user clicks cancel, your requiredfieldvalidator control will kick in and state you must have a value in the textbox.

    There is a way around this and that is using the "CausesValidation" property. CausesValidation can be added to many different ASP.NET controls. In this instance, you will want to add it to your cancel button control. See example below for more details.

 

 


       

   

  <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>

   <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

                               ErrorMessage="RequiredFieldValidator"

                               ControlToValidate="TextBox1">

   </asp:RequiredFieldValidator>

   <asp:Button ID="btnSubmit" runat="server" Text="Submit" />

   <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" />

 

 

   

     If you do not understand how this works or need help, please comment, and I'd be glad to help. Or feel free to go to our contact page and send us an e-mail.

 

 

Tags:

ASP.NET | C#.NET | Troubleshooting | Visual Studio 2005 | Visual Studio 2008 | Websites

Installing BlogEngine.Net in Visual Studio


by on 9. January 2010 07:26

I'm assuming if you are viewing this, you are experiencing some issues setting up BlogEngine.Net in your website. Your error may be along the lines of:

1. 500 - Internal Server Error

or

2. It is an error to use a section registered as allowDefinition=’MachineToApplication’ beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

Other posts have stated the issues of having sub-folders that have multiple web.config files, however, that is not necessarily the issue.

Goal: To integrate BlogEngine.Net into existing website in Visual Studio 2008 or Visual Studio 2005

Steps:

1. Separate your site's root folder from the blog folder.

2. Start Visual Studio 2008 or Visual Studio 2005 and go to File > Open Website.

3. Locate your blog folder and select Open.

4. Build website and View in browser. (Just to make sure everything is working accordingly)

5. On the Main toolbar, go to Website > Copy Website. (You can edit styles later, but for now, lets get it out on the web server.)

6. Once you connect via FTP, upload the files to your blog directory on your site.

7. Done! You should be running as normal.

 

*If you have any issues with this solution, or additional questions, feel free to ask/comment away.

 

www.z5concepts.com

 

Tags:

BlogEngine.Net | Troubleshooting | Visual Studio 2005 | Visual Studio 2008 | Websites


Theme by Z5 Concepts