TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
happyslug
NA
11
0
Field Validators and Post backs
Oct 4 2011 7:22 AM
I have a form which is mainly standard controls and an asp:table which I build in code
It all works fine until I start using field validators
Once I do on clicking my Save button, it performs the validation and shows the validationsummary - BUT this also involves a Post back - so the asp:table is wiped out.
Here is my Save button
<asp:ImageButton ID="BtnClientSave" runat="server" ValidationGroup="Servicegrp" ImageUrl="~/Images/Save.png"
OnClientClick="return BtnSaveClick()" OnClick="BtnClientSaveClick" Style="display: none" />
and my validation summary
<asp:ValidationSummary ID="valSummary" runat="server" DisplayMode="BulletList" ShowSummary="true"
ShowMessageBox="false" HeaderText="" ValidationGroup="Servicegrp" />
An example range validator
<asp:RangeValidator ID="rgeCurrentlyUnemployed" runat="server" ErrorMessage="Please Select an Unemployment Status"
Text="*" ControlToValidate="ddlCurrentlyUnemployed" MaximumValue="999999" MinimumValue="1"
ValidationGroup="Servicegrp"></asp:RangeValidator>
and my table
<asp:Table ID="QuestionTable" runat="server">
</asp:Table>
Reply
Answers (
6
)
0
Suthish Nair
0
30.5k
7.2m
Oct 5 2011 2:46 PM
prevent image button to post back,
refer
0
Javeed M Shaikh
274
6.7k
123.3k
Oct 4 2011 12:09 PM
lets take a step back and can you try the following:
<asp:TextBox id="TextBox1" runat="server"/>
<asp:RequiredFieldValidator ControlToValidate="TextBox1" ErrorMessage="Error in TextBox1" Text="*" runat="server"/>
<asp:Button id="b1" Text="Submit" runat="server"/>
<asp:ValidationSummary HeaderText="You must enter a value" DisplayMode="BulletList" EnableClientScript="true" runat="server"/>
0
happyslug
0
11
0
Oct 4 2011 11:00 AM
the problem is the contents of the table can be modified by the user - the table is essentially a number of checkboxes - and it will not yet have been saved - so doing this I would need to extract out what is already there, and re-do it - so more work than I want really.
0
Javeed M Shaikh
274
6.7k
123.3k
Oct 4 2011 10:54 AM
can you populate your table in the if not postback
0
happyslug
0
11
0
Oct 4 2011 10:49 AM
This had no effect. The table still disappeared.
0
Javeed M Shaikh
274
6.7k
123.3k
Oct 4 2011 10:09 AM
Please set the CausesValidation property of BtnClientSave to True.
Please do not forget to mark "Accepted Answer" .
Change the Empty cell in gridview to something else
Cannot insert value in database