The method Page.Validate() is called automatically by each of Microsoft's
submit controls (Button, ImageButton, and LinkButton) unless you set
CausesValidatio n to false. If its not called, you cannot use Page.IsValid as
you've found.
The submit controls call it in their OnClick method (which then fires your
Click event handler). It runs after Page_Load.
- Make sure CausesValidatio n=true or you call Page.Validate() before calling
Page.IsValid
- Don't call any of this from within Page_Load. Let it happen in the post
back event methods.
- If you are using CausesValidatio n=false because you don't want to validate
every validator, call individual validator's Validate() methods. Then check
the IsValid property on those individual validators.
- This is all server side code. It should not be affected by the browser
type.
- It is possible that if javascript is not working, your Click post back
event will not run. This happens when your submit control calls
__doPostBack() on the client-side to set itself up for server side
processing. Without javascript running, __doPostBack() never runs.
--- Peter Blum
www.PeterBlum.com
Email:
PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OF******** ********@TK2MSF TNGP14.phx.gbl. ..
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OS******** ******@TK2MSFTN GP09.phx.gbl... "TJS" <no****@here.co m> wrote in message
news:uN******** *****@TK2MSFTNG P15.phx.gbl... You're right, the function should not be called if the page is not valid
since it fails in both browsers, and you aren't prefilling the form, I
would need to see your code for "ModifyRecord_C lick" to determine of the
problem is there.
Actually, what I did to make it work is:
Sub ModifyRecord_Cl ick(sendor as Object, e as ImageClickEvent Args)
if not Page.isValid then
exit Sub
End If
I guessed the function does get called, so I just added that code to
solve the problem.
Now the problem is in my other routine, which is called by my LinkButton
(the Modify routine was called by an ImageButton).
The code is the same:
Sub DeleteProfile_C lick(sender as Object, e as EventArgs)
trace.warn("ins ide SelectProfile")
if not Page.isValid then
exit Sub
End If
But when I do it I get the error:
Page.IsValid cannot be called before validation has taken place. It should
be queried in the event handler for a control with CausesValidatio n=True
or after a call to Page.Validate.
So in the Modify function, the validate function is being called and in
the Delete function it is not ???????
Tom Tom