RadCaptcha error message not included in Validation Summary - asp.net

I have this code in my page that that has required field validation in the textboxes. The other controls are working fine(I have not included the other controls because its confusing) except for this radcaptcha. I have included it in the validation group but it is still not being displayed in the validation summary when it pops up. Thanks in advance.
<table>
<tr>
<td>
<asp:ValidationSummary ID="vs1" runat="server" BorderStyle="Solid" BorderWidth="1px"
Width="100%" Style="border-color: Black" BackColor="White" ForeColor="Red"
ValidationGroup="Group"></asp:ValidationSummary>
</td>
</tr>
<tr>
<td>
<div class="divContainer">
<telerik:RadCaptcha ID="RadCaptcha1" runat="server" ValidationGroup="Group" EnableRefreshImage="True" Display="Static" CssClass="CaptchaCss" Height="155px" Width="254px" CaptchaAudioLinkButtonText="" CaptchaLinkButtonText="" CaptchaImage-ImageCssClass="CaptchaImageCss" CaptchaImage-Width="231" CaptchaImage-Height="70" CaptchaTextBoxCssClass="rcTextBoxClass" CaptchaImage-EnableCaptchaAudio="True" CaptchaTextBoxLabelCssClass="rcLabelClass" ForeColor="#FFDC72" ErrorMessage="Invalid input"></telerik:RadCaptcha>
</div>
</td>
</tr>
</table>

Note that RadCaptcha performs the validation on the server, while the standard ASP.NET validation controls have client-side validation, which kicks in first, enabled by default. The client-side validation of all control in the validation group has to be disabled so that the error message of the captcha appears with the rest. You can check this in the link above.

Refer following link:
http://demos.telerik.com/aspnet-ajax/captcha/examples/validationsummary/defaultcs.aspx
You should use validationGroup property.

Related

How to disable future date in ajax calendarextender

I have an user control in AJAX for the date calendar and I want to disable the future dates in the Calendar. I have tried to do it by using the Maximum Value property but that doesn't disables the control.
Any suggestions or help?
<%# Control Language="C#" AutoEventWireup="true" CodeFile="usrCtrlDatePicker.ascx.cs" Inherits="UserControls_usrCtrlDatePicker" %>
<table cellspacing="0" cellpadding="0" border="0" style="height:18px;">
<tr>
<td style="text-align:center; vertical-align:middle; height:16px">
<asp:TextBox ID="txtDateEntry" runat="server" Width="75px" MaxLength="1" style="text-align:justify"/>
<img alt="" id="btnShowCalendar" runat="server" src="../images/calendar.gif" style="margin-left:-4px; margin-bottom:-3px; height:17px; width:17px;" />
<ajax:MaskedEditExtender ID="meeDateEntry" runat="server"
TargetControlID="txtDateEntry"
Mask="99/99/9999"
MessageValidatorTip="false"
CultureName="en-US"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Date"
ErrorTooltipEnabled="false" />
<ajax:MaskedEditValidator ID="mevDateEntry" runat="server" ControlExtender="meeDateEntry" ControlToValidate="txtDateEntry" Display="Dynamic" EmptyValueBlurredText="*" EmptyValueMessage="Date is required" InvalidValueBlurredMessage="*" InvalidValueMessage="Date is invalid" IsValidEmpty="false" MaximumValueBlurredMessage="sjdfhsdfh" MaximumValueMessage="Maximum Value Exceeded." TooltipMessage="" ValidationExpression="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" ValidationGroup="" />
<ajax:CalendarExtender ID="ceDateEntry" runat="server"
Format="MM/dd/yyyy"
TargetControlID="txtDateEntry"
PopupButtonID="btnShowCalendar" />
</td>
</tr>
</table>
You can use OnClientDateSelectionChanged event. Refer this.
I want to disable the future dates in the Asp.net ajax calendar extender
By setting the EndDate property of calendar extender you can achieve this required functionality or by using css class. css class technique is given below in the second link
For reference please check the following links, In the second link it uses css class to disable future dates.
Disable Future and Past Date
Disable Future Dates in ASP.Net AJAX

Foreign key table field not displaying within a standalone dynamic data enabled list view

I've gone through hundreds of Google result pages, trying to find an answer for this over the past couple of days.
Using a standalone dynamic data page to display a table, using an EntityDataSource, with one of the fields being a foreign key to a sub-table. I want it to display the value from the sub-table. I've been playing with a simplified case using the NorthWinds database (see code below). If I assign the DynamicControl a DataField="Supplier", it displays the sub-table/class name ("DAL.Supplier") instead. If I try assigning DataField="Supplier.CompanyName", it errors with "The table 'Product' does not have a column named 'Supplier.CompanyName'". Since I want to take advantage of dynamic data's editing features, using a templated field with <%# Eval("Supplier.CompanyName") %> is out.
Is this just not possible with a stand-alone dynamic data page? It clearly works fine within a fully scaffolded system. Or am I (hopefully) just missing something? Thank you.
Test.aspx
<%# Page Title="" Language="VB" MasterPageFile="~/Master/Site.master" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" Runat="Server">
<asp:ListView ID="ListView1" runat="server" DataSourceID="theDataSource" DataKeyNames="ProductID">
<ItemTemplate>
<tr>
<td>
<asp:DynamicControl runat="server" DataField="ProductID" Mode="Edit" />
</td>
<td>
<asp:DynamicControl runat="server" DataField="ProductName" Mode="Edit" />
</td>
<td>
<asp:DynamicControl runat="server" DataField="Supplier" Mode="Edit" />
</td>
<td>
<asp:DynamicControl runat="server" DataField="UnitPrice" Mode="Edit" />
</td>
<td>
<asp:DynamicControl runat="server" DataField="Discontinued" Mode="Edit" />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0">
<tr runat="server">
<th runat="server">
ProductID
</th>
<th runat="server">
ProductName
</th>
<th runat="server">
Supplier
</th>
<th runat="server">
UnitPrice
</th>
<th runat="server">
Discontinued
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
<asp:EntityDataSource ID="theDataSource" runat="server"
ConnectionString="name=NorthwindEntities"
DefaultContainerName="NorthwindEntities" EnableDelete="True"
EnableFlattening="False" EnableInsert="True" EnableUpdate="True"
Include="Supplier"
EntitySetName="Products">
</asp:EntityDataSource>
</asp:Content>
Test.aspx.vb
Imports System.Web.DynamicData
Imports DAL
Partial Class Test
Inherits System.Web.UI.Page
Protected table As MetaTable
Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
Listview1.EnableDynamicData(GetType(Product))
table = theDataSource.GetTable()
Title = table.DisplayName
End Sub
End Class
Problem solved. When all of this had started, I had originally gotten the error message:
Could not determine a MetaTable. A MetaTable could not be determined for the data source 'EntityDataSource1' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute
Trying to track that down led me to getting rid of the asp:DynamicDataManager markup, and replacing it in the code-behind with:
Listview1.EnableDynamicData(GetType(Product))
table = theDataSource.GetTable()
That turns out to have led me down the proverbial rabbit hole... While it got rid of the MetaTable error, it inadvertently caused the problem I wrote about above. Many thanks to: http://daviworld.net/?tag=/DynamicDataManager who points out that this error message is actually caused by:
This is due to an issue with the Designer code generation. When you select a DataSource for the GridView control, it does not add the ContextTypeName Attribute to the EntityDataSourceControl.
Once I removed the lines of code above, and added back in the asp:DynamicDataManager to the markup, and then added a ContextTypeName="DAL.NorthwindEntities" to the EntitiyDataSource, everything now works as one would wish it to.
Yeah true what u said. im at the same place where u got stuck. am running from pillar to post with fire in my belly but i guess it might extinguish soon.
how can it be so screwed up that u cannot work outside the scaffolding mechanism, all u are really doing is borrowing a dynamicdatamanager so u can stay templatised across both their framework and your newly added framework.
the way i got into this hole is when i try to display multiple entities data on the same page. thumb of rule seems to be single entity , single page. whatever im on da error for now. give it another few days before i open up the bottle again.. let there be beer !!!

Can RequiredFieldValidator have an effect on other elements on the page?

I have a basic form on my page with the following textbox and validator. When the validator is visible, there is a background image that is displayed. I would also like to be able to change the border of the textbox. Is that possible? If not in the ascx file, would it be possible in Javascript?
<tr>
<td class="FormLabel">First name*</td>
<td class="FormInput">
<asp:TextBox ID="txtFirstname" runat="server" Width="180" MaxLength="30" fieldname="FIRSTNAME" tablename="TblName"></asp:TextBox></td>
<td class="FormValidation">
<asp:RequiredFieldValidator ID="valFirstname" runat="server" ControlToValidate="txtFirstname" CssClass="ValidatorError"> </asp:RequiredFieldValidator></td>
</tr>
Thanks
If you would use a ValidatorCalloutExtender of the ASP.NET-Ajax-Control-Toolkit, this would be simple by applying an appropriate HighlightCssClass.

displaying custom message on custom errors in validation summary control on client side?

I am using validation summary control to display error messages of asp.net validation controls.
There are some validations in page for which validation controls are not being used. I am using custom javascript and jquery code for these. Kindly guide how I can display messages of these errors in validation summary control along with asp.net validation controls.
The key is to use the Custom Validation control. This control supports client side scripting (so you can still use your javascript code to do it) but still ties into the validation framework asp.net provides.
From the microsoft article, something like this:
<SCRIPT LANGUAGE="JavaScript">
function validateLength(oSrc, args){
args.IsValid = (args.Value.length >= 8);
}
</SCRIPT>
<asp:Textbox id="text1" runat="server" text="">
</asp:Textbox>
<asp:CustomValidator id="CustomValidator1" runat=server
ControlToValidate = "text1"
ErrorMessage = "You must enter at least 8 characters!"
ClientValidationFunction="validateLength" >
</asp:CustomValidator>
As Patrick said you can add the custom validator controls in place of your custom javascript/jQuery code. And then accordingly you can add the summary validation control. Also you can change the error message in your javascript code. Please check the below code for your reference.
<script type="text/javascript">
function validatetxtLength(source, args)
{
var txtVal=document.getElementById('<%=txtusername.ClientID %>').value;
if(txtVal=="")
{
document.getElementById('<%=custxtValidator.ClientID %>').setAttribute("errormessage","Please Enter the User Name");
args.IsValid=false;
}
else if(txtVal.length>9)
{
document.getElementById('<%=custxtValidator.ClientID %>').setAttribute("errormessage","Username must have less than 10 characters");
args.IsValid=false;
}
else
{
args.IsValid=true;
}
return;
}
</script>
<div>
<table cellpadding="0" cellspacing="0" border="0" width="712px">
<tr>
<td colspan="3" align="center">
Validator Testing
</td>
</tr>
<tr>
<td>
Please Enter your User Name:
</td>
<td>
<asp:TextBox ID="txtusername" runat="server" Width="150px"></asp:TextBox>
</td>
<td>
<asp:CustomValidator ID="custxtValidator" runat="server" ErrorMessage="User Name must have less than 10 characters"
Text="*" ForeColor="Red" ClientValidationFunction="validatetxtLength"></asp:CustomValidator>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Button ID="btnsubmit" runat="server" Text="Submit" />
</td>
</tr>
</table>
<asp:ValidationSummary ID="ValidationSummary1" HeaderText="Please check below validations:"
runat="server" DisplayMode="BulletList" EnableClientScript="true" />
</div>
This might be useful for you.

Recaptcha ErrorMessage Property in ASP.NET

I am using recaptcha in an ASP.NET 3.5 application and for some odd reason the ErrorMessage property is not working. Below is my code
<recaptcha:RecaptchaControl ID="recaptcha" runat="server" PublicKey="*******************************" PrivateKey="*******************" Theme="white" ErrorMessage="This is an typo error" />
When the typed text doesn't match with the recaptcha image text it still shows the default error message "Incorrect. Try again." instead of my custom error message. What could be the reason for this strange behavior
You put the message in a Literal tag. Here is my code snippet:
<tr>
<td align="center" colspan="2" >
<recaptcha:RecaptchaControl Theme="white" ID="recaptcha" runat="server" PrivateKey="*************"
PublicKey="*************" />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: red">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False" Text="You have not entered the verification words correctly. Please try again."></asp:Literal>
</td>
</tr>
Mike

Resources