|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
custom validator and button eventsHi,
I have a program with a textbox, customvalidator and button. <asp:TextBox ID="txtName" Runat="server" MaxLength="30" AutoPostBack="True" CausesValidation="True"></asp:TextBox> <asp:CustomValidator ID="CVltxtNombre" Runat="server" ControlToValidate="txtName" Display="Dynamic" OnServerValidate="CVltxtNombre_ServerValidate"asp:CustomValidator> <asp:Button ID="btnGo" Runat="server" Text="Go" OnClick="btnGo_Click" /> I want to save in Database the textbox.text. If I want to modify one database record, I get the record and put it in the textbox. When I change the textbox.text and press button go, goes to CVltxtNombre_ServerValidate event because it has been a change. But after this it doesn't go to btnGo_Click event. Why? If Page.IsValid is true, why doesn't it go to Button event? Can any help me?? I'm using .NET 2005 beta 1 Just so you know, your button event should get called always, even if Validation
fails. IN the Button event you should always check IsValid before writing data to the database. Do you submit by clicking the button or by pressing enter on the form? -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > Hi, > I have a program with a textbox, customvalidator and button. > <asp:TextBox ID="txtName" Runat="server" MaxLength="30" > AutoPostBack="True" CausesValidation="True"></asp:TextBox> > <asp:CustomValidator ID="CVltxtNombre" Runat="server" > ControlToValidate="txtName" Display="Dynamic" > OnServerValidate="CVltxtNombre_ServerValidate"asp:CustomValidator> > <asp:Button ID="btnGo" Runat="server" Text="Go" OnClick="btnGo_Click" > /> > I want to save in Database the textbox.text. If I want to modify one > database record, I get the record and put it in the textbox. When I > change the textbox.text and press button go, goes to > CVltxtNombre_ServerValidate event because it has been a change. But > after this it doesn't go to btnGo_Click event. Why? If Page.IsValid is > true, why doesn't it go to Button event? > Can any help me?? I'm using .NET 2005 beta 1 Hi Brock. Thanks for answering. I have this custom validator event:
Sub CVltxtNombre_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Try If .... Then End If Catch ex As Exception args.IsValid = False txtNombre.Focus() End Try End Sub I have a button event: Sub btnGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Page.IsValid Then Insert() End If End Sub When I change de textbox.text and click button, program goes FIRST to CVltxtNombre_ServerValidate because it has been a change in the textbox and then doesn't go to btnGo_Click event (Page is valid). I don't know why button event is not been called. I want submit by clicking the button. Thanks again. Show quoteHide quote > Just so you know, your button event should get called always, even if Validation > fails. IN the Button event you should always check IsValid before writing > data to the database. > > Do you submit by clicking the button or by pressing enter on the form? > > -Brock > DevelopMentor > http://staff.develop.com/ballen > > > > When I change de textbox.text and click button, program goes FIRST to The Validator should always get called. So should your button. I'm not sure > CVltxtNombre_ServerValidate because it has been a change in the > textbox and then doesn't go to btnGo_Click event (Page is valid). I > don't know why button event is not been called. I want submit by > clicking the button. why it's not getting called. -Brock DevelopMentor http://staff.develop.com/ballen
Other interesting topics
IE Web Controls - discontinued ???
Re: At which life cycle should EnsureChildControls() be called? Dynamically resize a DropDownList in a grid when dropped down How to call javascript when click update command(it Edit command c Cant Render Page Control with Visual Studio 2005 Beta Urgent User COntrol set dropdownlist value in datalist IE6 Style Buttons Custom Templated Control not rendering asp.net controls correctly Enter Key form with many UserControls |
|||||||||||||||||||||||