.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

Page Validation

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
I'm using the validation to validate textboxes. I have a Cancel button. I would like to be able to cancel the page if the user wish, but something has to be in the textbox for it to work. How can I get around that problem. If the user opens the page then wish to cancel it before entering any data??? 

View Complete Post

More Related Resource Links

Multiple forms on the same page MVC2: how to handle (including validation from model)



It should be simple; although I'm having a hard time to figure out the best way to do it. I've MVC2 pages with multiple forms on the same page having different functionalities.

What's the best way to handle this; including the MVC2 way of validation from the model?


Page.IsValid cannot be called before validation has taken place

This is my first asp.net application and it looks like I am in a rock and a hard place.  I have a multi page formview and I want to allow the user to page back with causing validation, but if I don't cause validation on the page back button, I get an error  Page.IsValid cannot be called before validation has taken place. It should be queried in the event handler for a control that has CausesValidation=True and initiated the postback, or after a call to Page.Validate.Source Error:  Line 41: Line 42:     Protected Sub FormView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewPageEventArgs) Handles FormView1.PageIndexChangingLine 43:         FormView1.UpdateItem(True)Line 44:         If FormView1.PageIndex < 1 ThenLine 45:             FormView1.FindControl("ImpactsTextBox").Focus() Line 43 in the vb file allows me to update an item.   How do I get around this problem?  Is this where I need a "if not postback"?  Any examples would be appreciated.  

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.

ASP.Net Page Validation and Window Unload

I am getting some weird issue on my asp.net page.Here is the scenario:I have a asp.net page with a textbox (ctrl#1) and a dropdown control (ctrl#2). Each control have their CausesValidation and AutoPostBack set to true. I have another dropdown control (ctrl#3) on the same page which allows the user to navigate to some other page. I have added an alert message for the user (on window.onbeforeunload event) to warn the user of any unsaved changes on the page. User can choose to stay on the current page by clicking Cancel.So far so good... All works fine when the data is changed on the page  and user tries to navigate away from the current page using the above dropdown control (ctrl#3). The window.onbeforeunload fires and user gets the alert message. Happy user.Now comes the issue....When there is any invalid data on the page and the asp.net validation has fired, now, when the user tries to navigate away from the current page, he does not get any alert. It seems as if the window.onbeforeunload does not fire in this case when there is invalid data on page. I am not sure why this is happening!Can someone please share some thoughts and/or suggest a solution please?

Validation summary not showing in master page

Hi, I am using User controls in my web page. I have validation controls in my user control and the validation summary control is placed in the master page. Problem is I am not getting the errors displayed when I am running my application. Any help is appreciated.   Thanks.

SharePoint 201 VS 2010 WF: PersistenceException: The security validation for this page is invalid


Setup: Visual studio 2010 SharePoint 2010 Workflow with custom infopath task edit form, with file attachment control. If I attach a file to the infopath task edit form, I got the following error message, though the attachment is saved, but the next task is not created and the current task is not marked as completed either.

09/27/2010 15:34:31.18     w3wp.exe (0x2B88)                           0x2844    SharePoint Foundation             Workflow Infrastructure           88xr    Unexpected    WinWF Internal Error, terminating workflow Id# 04621f32-17d4-439a-883a-7566b96481bb     
09/27/2010 15:34:31.18     w3wp.exe (0x2B88)                           0x2844    SharePoint Foundation             Workflow Infrastructure           98d4    Unexpected    System.Workflow.Runtime.Hosting.Pers

1 page, 2 validationgroups and 2 validation summary issues


Hi all,

I have one page, on which I have a part with controls and one validationgroup, with the respective validation summary.

I have another part on the same page with another validation group, and another validation summary.

The thing is that, when I press btnGo or btnGo2, both validationsummaries trigger, and both show all validation messages. For other words, it seems that the validationgroups are not working.

My html:

<!--Group 1-->
<tr style="padding-top:3px;">
    <td class="mgmCell">
    <td style="padding-left:5px;">
        <asp:TextBox ID="txtName" runat="server" ValidationGroup="Group1"/>
        <asp:RequiredFieldValidator ID="rfvName" runat="server" ErrorMessage="Name" Text="*" ValidationGroup="Group1" ControlToValidate="txtName" />
    <td colspan="2">
        <asp:Button ID="btnGo" runat="server" Text="Go" ValidationGroup="Group1" OnClick="ClickEvent" />
        <asp:ValidationSummary ID="vs1" runat="server" ShowSummary="fal

jquery validation in ascx page


Following on from my post about using ascx pages for the content of the jquery tab panels.


Can I use jquery validation on each ascx page before submitting to move to the next tab panel?

I've been trying the following way, but when I click the submit button I get the error 'Object doesn't support this property or method'.


<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
    <div id="tabs">
            <li><a href="#tab1">Your Details</a></li>
            <li><a href="#tab2">Course Details</a></li>
            <li><a href="#tab3">Education & Employment</a></li>
            <li><a href="#tab4">References</a></li>
            <li><a href="#tab5">Submit Application</a></li>
        <div id="tab1">
            <asp:PlaceHolder ID="plhApp" runat="server"></asp:PlaceHolder>

Page IS Valid Validation Error and Message Box Pops up twice which is annoying???




i have a create User Wizard with a Custom Template so I can grab more information from the user who is

registering on my page.  When they click the submit button a window modal popup extender pops up using Javascript code to

show them the Form is being processed.


createUserWizard Submit Button

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  OnClientClick="ShowMP();" align="middle" CausesValidation="False"
                                            Text="Submit my Profile"  />


Javascript code<

Return to top of page during form validation


I have a asp.net form that is vaildating required fields. The validation is working fine EXCEPT when I click the submit button the form stays on the bottom of the page. I need the code for on focus to the first invalid field.

stop postback after imagebutton click on page validation error



i have some textbox that i validate with a customvalidator control (only, and must be, server side function) and i have an imagebutton control for submit.

I must stop the postback if there are some errors in the validation function.

I set the validation property argumets.isvalid = false in the customvalidator function but doesn't work, the postback continue.

i have tried to set the imagebutton property postbackurl = "" in the validation function but doesn't work.

Where is the error?

Page Error Validation Exception


hello fellows

i would very much like to capture certain dal/bll exceptions in my page_error code and turn them into validation errors

so they should show up in the validationsummary

this is the code im trying now

    Protected Overrides Sub OnError(ByVal e As EventArgs)
Dim ex = Server.GetLastError
If ex.GetType = (New ArgumentException).GetType Then
Dim validator = New CustomValidator
validator.IsValid = False
validator.ErrorMessage = CType(ex, ArgumentException).Message
End If
End Sub
End Class

the logic is simply to catch only exceptions of type ArgumentException, otherwise it should bubble up (to global.asax handling)

what hapens is that after this code block runs, the exception still exists in the system, so it always bubbles up to the global.asax

it there any way to tell asp.net that "its ok, i took care of the exception, just continue with the page"?

i tried server.clearerror and context.clearerror but these methods stop the whole page and return a blank empty page

thank you all for your time and patience

p.s. if u have any other ideas 4 improving this code, pl

The security validation for this page is invalid


I have SharePoint 2010 installed in a lab and have encountered an error:

"The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."

This occurs when trying to modify a list's view in order to change a default sort order and possibly other properties on that list.  I read that one can disable validation in Central Admin > Web Applications > General Settings, and that although this is not recommended, it did allow me to save modifications to a view.  Unfortunately, switching security validation off causes the Silverlight popups that allow creating new document libraries, pages, etc no longer works.  The error is:

"Error, An unhandled exception occurred in the Silverlight Application"

There are no features, or other custom code running.  This is a plain install of SharePoint 2010.

This seems to be happening on the My Sites site collection.  When I am logged in as the farm admin, I don't receive this error.  But if I am logged in as normal user, who does have site ownership - full control - the error occurs.

My environment is configured like:

http://lab.contoso.com - Top level publishing site

http://lab.contoso.com/members/sites - My Sites (members is a managed

Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Reduce ASP.NET Page size and complexity using JQuery

This is my first post on asp.net blog. ASP.NET Ajax and JQuery are two different ajax framework. In this post I will show, how we can enhance gridview using ASP.NET Ajax and JQuery. I also compare the implementation of these frameworks. In next posts i will explain more about JQuery and ASP.NET Ajax and also tell you "How to combine the power of both framework". My Future post will related to ASP.NET and related frameworks.


I have 2 web pages. First page has a textbox and a button control.

when I enter test and click on the button , system goes to the second page. And in the second page I want to access the Textbox in the first page. When I try to do this I get the following error.

"Object reference not set to an instance of an object. Following is my code :

Dim txt As New TextBox

' Find the server name on the previous page
txt = CType(Page.PreviousPage.FindControl("TextBox2"), TextBox)
If Not IsNothing(txt) Then
Response.Write("[Name Not available]")
End If

I know I could do this with session, but I want to use the Page.PreviousPage.FindControl. Any help is greatly appreciated
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