Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > ASP and ASP.NET
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 08-24-2005, 03:17 PM
  #1
gzieve
Aspirant (Level 2)
 
Join Date: Apr 2002
Posts: 13
iTrader: (0)
gzieve is on a distinguished road
.NET RequiredFieldValidator stops working after first submit

I am using VS.NET with VB.NET. I have a page with a submit button and a reset button and several text boxes. A RequiredFieldValidator ensures that the 2 required text boxes are filled. The reset button just clears out all the fields. The RequiredFieldValidator works only when the page is first loaded, but if I submit the page or reset the page, it no longer works....the page loads like it's not even there. If I go to another page on the site and then come back to that page, it works again. What do I have to change?
gzieve is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-24-2005, 03:58 PM
  #2
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
I have never seen that occur. Can you post your code?
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2005, 08:15 AM
  #3
gzieve
Aspirant (Level 2)
 
Join Date: Apr 2002
Posts: 13
iTrader: (0)
gzieve is on a distinguished road
I'm not sure how much you want, b/c there's a lot of code in the code behind page.

On the HTML page, these are the textboxes...

Code:
			
<TR>
<TD style="WIDTH: 126px; HEIGHT: 26px">
     Study Code:*
</TD>
<TD style="WIDTH: 206px; HEIGHT: 26px">
     <asp:textbox id="txtstudycode"   
              Runat="server" Columns="24" MaxLength="24"></asp:textbox>
</TD>	
</TR>
<tr>
<TD style="WIDTH: 126px; HEIGHT: 28px">
              Study Name:* 
</TD>
<TD style="WIDTH: 206px; HEIGHT: 28px">
     <asp:textbox id="txtstudyname" Runat="server" Columns="24"  
      MaxLength="24"></asp:textbox>
</TD>
</tr>
These are the validators....
Code:
<asp:RequiredFieldValidator id="valStudyCode" style="Z-INDEX: 104; LEFT: 24px; 
POSITION: absolute; TOP: 192px" runat="server" Font-Size="Smaller" ControlToValidate="txtstudycode" 
ErrorMessage="Required Field: Study Code is 
Required"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator id="valStudyName" style="Z-INDEX: 105; LEFT: 24px; 
POSITION: absolute; TOP: 208px" runat="server" Font-Size="Smaller" 
ControlToValidate="txtstudyname" 
ErrorMessage="Required Field: Study Name is 
Required"></asp:RequiredFieldValidator></DIV>

Here is what I think may be relevant in the code behind page.
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not (Page.IsPostBack) Then
                chech_admin()
                BindTheTA()
                BindThePhase()
                BindTheCSL()
            End If
            changetabs()
End Sub

Private Sub lnksubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnksubmit.Click
            insert_study()
End Sub

Private Sub lnkReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkReset.Click
            clear_all()
End Sub


Sub insert_study()
   (code here)       
 End Sub

Sub clear_all()
 (code here clears all fields)          
End Sub

Last edited by gzieve : 08-25-2005 at 08:30 AM. Reason: Submitted reply by mistake before I was finished
gzieve is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2005, 08:20 AM
  #4
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
ok i have a few questions here. Where are those placed at??? I do not see them.

You should also do

Page.IsValid checks just as you would do Page.IsPostBack check to insure no re-binding of the data.

IsValid validates subcontrols also.
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2005, 08:36 AM
  #5
gzieve
Aspirant (Level 2)
 
Join Date: Apr 2002
Posts: 13
iTrader: (0)
gzieve is on a distinguished road
Sorry...I entered the my reply before I was finished (was tabbing down and hit post by mistake!)...I just went back and edited it, so take another look as there's more code now.

I just added Page.IsValid here, but it had no effect.

Code:
Private Sub lnksubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnksubmit.Click
            If Page.IsValid Then
                insert_study()
            End If
 End Sub

Last edited by gzieve : 08-25-2005 at 08:53 AM. Reason: clarification
gzieve is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2005, 08:56 AM
  #6
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
the reset button button ??? that should just be a plain html control not a webcontrol . I suggest that you use that instead.
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2005, 09:16 AM
  #7
gzieve
Aspirant (Level 2)
 
Join Date: Apr 2002
Posts: 13
iTrader: (0)
gzieve is on a distinguished road
I'll do that, or I'll just use javascript to validate instead...thanks!
gzieve is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 08-25-2005, 10:20 AM
  #8
afterburn
Can't say much here
 
afterburn's Avatar
 
Join Date: May 2004
Posts: 2,851
iTrader: (0)
afterburn will become famous soon enough
Required field validators work well and if you use them then it not only checks on the client side. but on the server side if not validated correctly on client. So I would try to correct what you have unless you want to write more code for the server...
__________________
ASP.net nice bits
Code Smith rocking tool for Code Generation in any language (Written in .net)
Red Gate SQL tools for DBA
Blog Personal blog
.afterburn
afterburn is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 10:40 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.