ValidatorCalloutExtender not working in Asp.net Ajax - asp.net

I have a RadioButtonList with Yes and No Option.Upon clicking the Yes button,Textbox1 and TextBox2 will be displayed and clicking No button Textbox3 and Textbox4 will be displayed.All the above the textboxes have ValidatorCalloutExtender.Upon clicking the Submit Button, the ValidatorCalloutExtender is not popup.Can any please help me..
Here is the code sample:
<asp:RequiredFieldValidator ID="rfvENo" runat="server" ControlToValidate="txt1"
Display="None" ErrorMessage="Please Enter ENo!" ValidationGroup="Agent" />
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender10" runat="server" Enabled="True"
TargetControlID="rfvENo">
</cc1:ValidatorCalloutExtender>

Do you have the correct ValidationGroup="Agent" set on the submit button? Your code is working fine for me otherwise.

It requires a class to work
<asp:RequiredFieldValidator ID="rfvAddCubicFeet" runat="server" ControlToValidate="txtAddCubicFeet" Display="Dynamic" ErrorMessage='<br/>Enter the total cubic feet.' ValidationGroup="vgAdd" Enabled="False"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender9" runat="server" HighlightCssClass="validatorCalloutHighlight" TargetControlID="rfvAddCubicFeet"></cc1:ValidatorCalloutExtender>

Related

RegularExpressionValidator in Asp.net

I have search textbox,which has default value Enter Month to View Profit. When I click search button without entering any data, the default value of textbox is posted to server for search. I want that RegularExpressionValidator do not validate default value of textbox.
<asp:TextBox ID="Tboxsearch" Text="Enter Month to View Profit" OnClick="this.value=''" CssClass="textboxinput" runat="server"></asp:TextBox>
<asp:Button ID="ButtonSearch" CssClass="btnLog" runat="server" Text="Search" onclick="ButtonSearch_Click" />
<asp:RequiredFieldValidator
ID="RequiredFieldValidatorname"
runat="server"
ControlToValidate="Tboxsearch"
ForeColor="Red"
Text="*"
>
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidatorname"
runat="server"
ValidationExpression="[a-zA-Z0-9]+"
ForeColor="Red"
ControlToValidate="Tboxsearch"
ErrorMessage="Enter Valid Name!"
>
</asp:RegularExpressionValidator>
The default for all validators except the RequiredFieldValidator control if you post with empty field the validator will not trigger
you must use required field validator with other validators to prevent the postback to happen
from MSDN
Special-Case Validation Results for ASP.NET Server Controls
EDIT
Also if you add your controls as in your question it should work but if there is other controls like for example other button you should set the validationGroup Property to the group that you want to work together
ValidationGroup="vGrp"
and your code will be like this
<asp:TextBox ID="Tboxsearch" Text="Enter Month to View Profit" OnClick="this.value=''" CssClass="textboxinput" runat="server" ValidationGroup="vGrp"></asp:TextBox>
<asp:Button ID="ButtonSearch" CssClass="btnLog" runat="server" Text="Search" onclick="ButtonSearch_Click" ValidationGroup="vGrp" />
<asp:RequiredFieldValidator
ID="RequiredFieldValidatorname"
runat="server"
ControlToValidate="Tboxsearch"
ForeColor="Red"
Text="*"
ValidationGroup="vGrp">
</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator
ID="RegularExpressionValidatorname"
runat="server"
ValidationExpression="[a-zA-Z0-9]+"
ForeColor="Red"
ControlToValidate="Tboxsearch"
ErrorMessage="Enter Valid Name!" ValidationGroup="vGrp"></asp:RegularExpressionValidator>
from MSDN about validationGroup

No validation on lost focus calendarextender

I have calendarextender for a textbox. I need do the requiredfiled validation after lost focus. But the code below doesn't show red * after lost focus.
<asp:TextBox ID="txtDateS" runat="server" Width="80px"/>
<cc1:calendarextender ID="ceDateS" runat="server" CssClass="cal" Enabled="True" TargetControlID="txtDateS" />
<asp:RequiredFieldValidator ID="rfvDates" runat="server" ErrorMessage="RequiredFieldValidator" Text="*" ControlToValidate="txtDateS"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="rfvDates_ValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="rfvDates"></cc1:ValidatorCalloutExtender>
The RequiredFieldValidator doesn't fire when the control loses focus (unless you've previously entered text and then removed it), what you can try is to add the following to the page load event:
txtDateS.Attributes.Add("onblur", "ValidatorOnChange(event);")

Prevent textbox from firing validators

So I have a textbox with 6 validators. 2 of each kind because I have two validation groups depending on what button the user clicks. My problem is everytime the textbox loses focus two error messages get displayed, and this looks wierd. I've tried setting the CausesValidation property of the textbox to "false" but it's not working.
Textbox & Validators -
<asp:TextBox ID="collectionDtl_Qty" runat="server" CssClass="formText"
AutoPostBack="false" CausesValidation="false" Text="0">
</asp:TextBox>
<asp:FilteredTextBoxExtender ID="collectionDtl_Qty_Filtered" runat="server"
FilterMode="ValidChars" TargetControlID="collectionDtl_Qty" ValidChars="1234567890,">
</asp:FilteredTextBoxExtender>
<asp:CustomValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_CValidator"
runat="server" ClientValidationFunction="coll_QtyValidator"
Text="Quantity cannot be greater than requested quantity." ForeColor="Red"
ValidationGroup="formValidation" Display="Dynamic">
</asp:CustomValidator>
<asp:CustomValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_CValidator2"
runat="server" ClientValidationFunction="coll_QtyValidator"
Text="Quantity cannot be greater than requested quantity." ForeColor="Red"
ValidationGroup="detailValidation" Display="Dynamic">
</asp:CustomValidator>
<asp:CompareValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_Comparer"
runat="server" Text="Quantity must be greater than 0." ForeColor="Red"
ValidationGroup="formValidation" Display="Dynamic"
ValueToCompare="0" Operator="GreaterThan" Type="Integer">
</asp:CompareValidator>
<asp:CompareValidator ControlToValidate="collectionDtl_Qty" ID="collectionDtl_Qty_Comparer2"
runat="server" Text="Quantity must be greater than 0." ForeColor="Red"
ValidationGroup="detailValidation" Display="Dynamic"
ValueToCompare="0" Operator="GreaterThan" Type="Integer">
</asp:CompareValidator>
Any help would be appreciated.
Hi according to your question.what i understand you have to disabled validator or use validation based on Button click.
For Button click use ValidationGroup
ValidationGroup="save"
If you want to disabled validators on condition .Try this one
ValidatorEnable(document.getElementById('<%= rqrgvddlCategory.ClientID %>'), false);
Hope it will helps you.

Multiple ASP.NET validators

I have an ASP.NET page with the following code.
<asp:TextBoxEx ID="CompSCEmail" MaxLength="100" runat="server"></asp:TextBoxEx> <asp:RegularExpressionValidator Display="Dynamic" ID="RegSubmitCompSCEmail" runat="Server" ControlToValidate ="CompSCEmail" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*" ErrorMessage="(*)"></asp:RegularExpressionValidator>
<asp:ImageButton ID="SubmitButton" SkinID="submitButton" OnClick="SubmitButton_Click"
Action="Submit" ValidationGroup="submit" runat="server" VisibleOnRecall="false" />
<asp:ImageButton ID="SaveButton" SkinID="saveButton" OnClick="SaveButton_Click" Action="Save" runat="server" Visible="true" VisibleOnRecall="makerfirst" />
I want to validate the format of the email when the user click both "Submit" and "Save" button. Does anyone know how to do that?
Thank You.
Give your RegularExpressionValidator ValidationGroup Property.
On click of both of your Buttons call Page.Validate("yourvalidationgroup").
This way you can validate email on click of both the buttons.

validation control in asp.net with masterpage buttons

I have a lot of textboxes on submit page and all have a validator. I want to control them with a submit button which is on master page. It works but other buttons also cause validation. validation summary is always shown either submit button is clicked or any other buttons. how can I control this situation? (asp.net)
for each individual submit use "ValidationGroup". here is the sample:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox1" ValidationGroup="Submit" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox2" ValidationGroup="Submit" ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" ValidationGroup="Submit" runat="server" Text="Button" />
I think you can resolve this by using ValidationGroup Property..
http://msdn.microsoft.com/en-us/library/ms227424.aspx
http://www.w3schools.com/aspnet/prop_webcontrol_imagebutton_validationgroup.asp
Thanks
Deepu

Resources