issue with validation in asp.net mvc3 - asp.net-mvc-3

i am system.datamodel.dataannotation for validating my views.
below is my Model for the view.
using System.ComponentModel.DataAnnotations;
public class LoginVM
{
[Required(ErrorMessage="Please provide UserName")]
public string UserName { get; set; }
public string Password { get; set; }
}
below is my view for Login
<% using (Html.BeginForm())
{ %>
<% Html.ValidationSummary(true); %>
<div style="width: 100%; height: 100%; border-style: none;">
<fieldset style="border-style: none;">
<table style="width: 100%; height: 100%; border-style: none;" border="0">
<tr>
<td style="height: 100px;" colspan="4">
</td>
<td class="editor-label" style="width: 35%; font-size: medium; vertical-align: top;
text-align: justify;">
<%: Html.Label("Sign in with your Account Credentials")%><br />
<br />
Support / Contact Us
</td>
<td style="width: 5%;">
</td>
<td style="width: 60%; border-left-width: 2px; border-left-color: #E3E3E3; border-left-style: solid;">
<table style="border-style: none;" border="0">
<tr>
<td colspan="3">
</td>
</tr>
<tr style="height: 30px;">
<td style="width: 20%;" class="login-display-label">
<%: Html.LabelFor(m=>m.UserName,"UserName :") %><br />
<br />
<%: Html.LabelFor(m=>m.Password,"Password :") %><br />
<br />
</td>
<td style="width: 182px;" colspan="2">
<%: Html.TextBoxFor(m=>m.UserName,"UserName :")%><br />
<%: Html.ValidationMessageFor(m=>m.UserName) %><br />
<%: Html.TextBoxFor(m=>m.Password,"Password :")%><br />
<%: Html.ValidationMessageFor(m=>m.Password) %><br />
</td>
</tr>
<tr>
<td>
&nbsp
</td>
<td style="width: 182px;" colspan="3">
<input type="button" id="btnSubmit" value="Submit" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</fieldset>
</div>
below is the scripts i have putted on my view as well as my site.master page
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>
i have also checked my web.config for below markup
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
after lots of effort my validation doesnt occur please help me....
let me known what necessary change i have to make.
thnaks in advance

change javascript Address:
<script src="#Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
and Html Helper
Html.TextBoxFor(m=>m.UserName)

Related

Xpath of checkbox inside iframe inside div

for the life of me, I cannot get the xpath of this....
i think the problem is that there are two divs one, called 'div_settings_A' and 'div_settings_C', in the example below you cant see the 'div_settings_C' because its hidden, just cant put my finger on why it wont work!
I have tried
//div[contains(#id, 'div_settings_A')]/input
//tr[#id='inputSavePaymentAccounts'] and td[#name='payAck']
<iframe id="ccPayWiz" class="ui-dialog-content ui-widget-content" src="ccxPaymentDetails.php?c=1805&a=733344&d=null&m=Automation#billtrust.com&b=768866910" style="width: 99%; min-height: 105.833px; height: 717px; position: relative;" scrolltop="0" scrollleft="0">
<!DOCTYPE html>
<html>
<head>
<body style="border: 0px; margin: 0px; padding: 0px;" onload="setuppanes('IG');">
<input id="wpsURL" type="hidden" value="WPS_URL">
<form id="frmPay" onsubmit="return paywizAccountHelper.validateForm(this, '17', 'US');" action="ccProcessPayment.php" method="post" name="frmPay">
<input type="hidden" name="csrf" value="e5297f08b85318aa2ec176a5d8fac2a2">
<div id="divPayWizard2">
<div style="float:left; margin-top:5px">
<ul class="steps ui-widget ui-helper-clearfix">
<li>
<li>
<li>
</ul>
</div>
<br clear="all">
<hr>
<p>
<span class="cc-font"> Enter the customer's billing information to process the payment.</span>
</p>
<div id="divpane1">
<table id="tablepane1" class="cc-pane1-table cc-font">
<br>
</div>
<div id="divpane2">
<table class="cc-pane2-table-top cc-font">
</div>
<div id="div_settings_A" style="display: block;">
<input type="hidden" value="733344" name="SrchAcctNum">
<table class="cc-font" width="700" cellspacing="3" border="0">
<input id="BankCountry" type="hidden" value="US" name="BankCountry">
<tbody>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr>
<tr id="inputSavePaymentAccounts" class="savePaymentAccounts" style="display: table-row;">
<td class="addCCLabel" style="padding-top: 15px">Save this Payment Method</td>
<td style="padding-top: 15px">
<input class="payAck" type="checkbox" name="payAck" style="margin: 0; padding 0" tabindex="9">
</td>
</tr>
You can directly get that ccheck box element by using name attribute as :
.//input[#type = 'checkbox' and #name = 'payAck']
Or if there are multiple check boxes with the same name then try using descendant of tr as :
.//tr[#id = 'inputSavePaymentAccounts']/descendant::input[#type = 'checkbox' and #name = 'payAck']
Or
.//tr[#id = 'inputSavePaymentAccounts']/descendant::input
Hope it helps...:)

Ajax Modalpop up error

I have added a modal popextender
when i click on Edit button i ma getting following error.
Unhandled exception at line 1, column 55504 in http://localhost:59846/bundles/MsAjaxJs?v=c42ygB2U07n37m_Sfa8ZbLGVu4Rr2gsBo7MvUEnJeZ81
0x800a138f - JavaScript runtime error: Unable to get property '_events' of undefined or null reference
If there is a handler for this exception, the program may be safely continued.
Unhandled exception at line 1, column 55504 in http://localhost:59846/bundles/MsAjaxJs?
I have two pages View.aspx and AddEdit.aspx
On click of Edit button of View.aspx , Another page AddEdit.aspx in Modalpopup should be opened.
I am using AjaxControlTookit version 15.1.3.0
View.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="View.aspx.cs" Inherits="TransitionAutomationPlatform.WebApp.Templates.ContractSummaryNote.View" %>
<%# Register Src="../../UserControls/ucProcessInfo.ascx" TagName="ucProcessInfo" TagPrefix="uc1" %>
<%# Register Src="../../UserControls/ucGridActions.ascx" TagName="ucGridActions" TagPrefix="uc2" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<style type="text/css">
.DarkenBackground {
background-color: rgb(0, 0, 0);
opacity: 0.7; /* Safari, Opera */
filter: alpha(opacity=70); /* IE */
z-index: 20;
height: 100%;
width: 100%;
background-repeat: repeat;
position: fixed;
top: 0px;
left: 0px;
}
.ModalPopup {
background-color: #003e74;
filter: alpha(opacity=100); /* IE */
font-family: Verdana;
border-style: solid;
border-width: 0.75pt;
border-color: White;
}
.ModalPopup h {
background-color: #003e74;
filter: alpha(opacity=100); /* IE */
font-family: Verdana;
}
.GridViewFixedHeader {
position: relative;
color: White;
background-color: #646464;
}
.GridScrollBar {
overflow-y: auto;
height: 200px;
width: 300px;
}
.DefaultCursor {
cursor: default;
}
.MainPageTable {
border-collapse: collapse;
padding: 0;
margin: 0;
}
.ModalTable {
height: 100%;
width: 95%;
margin-left: auto;
margin-right: auto;
}
.ModalTableLabelTD {
font-size: 8pt;
font-weight: bold;
color: White;
width: 25%;
}
.ModalTableControlTD {
width: 160px;
}
.GridViewResult {
background-color: White;
width: 282px;
padding: 20px;
}
.GridViewResultRows {
color: Black;
background-color: White;
height: 30px;
}
</style>
<link href="../../Content/jquery.dataTables.css" rel="stylesheet" />
<link href="../../Content/TableTools.css" rel="stylesheet" />
<script src="../Datatables_Latest/jquery-1.11.3.min.js"></script>
<link href="../../Scripts/Datatables_Latest/jquery-ui-1.11.3/jquery-ui-1.11.3/jquery-ui.css" rel="stylesheet" />
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="../../Scripts/Datatables_Latest/jquery-ui-1.11.3/jquery-ui-1.11.3/jquery-ui.js"></script>
<script src="../../Scripts/Datatables_Latest/jquery-ui-1.11.3/jquery-ui-1.11.3/jquery-ui.min.js"></script>
<script src="../../Scripts/jquery-1.10.2.min.js"></script>
<script src="../../Scripts/jquery-ui.min.js"></script>
<script src="../../Scripts/Datatables_Latest/jquery.dataTables.min.js"></script>
<%-- <script src="../../Scripts/jquery.dataTables.min.js"></script>--%>
<script src="../../Scripts/dataTables.buttons.min.js"></script>
<script src="../../Scripts/Datatables_Latest/buttons.flash.min.js"></script>
<script src="../../Scripts/Datatables_Latest/jszip.js"></script>
<script src="../../Scripts/Datatables_Latest/jszip.min.js"></script>
<script src="../../Scripts/Datatables_Latest/pdfmake.min.js"></script>
<script src="../../Scripts/Datatables_Latest/vfs_fonts.js"></script>
<script src="../../Scripts/Datatables_Latest/buttons.html5.min.js"></script>
<script src="../../Scripts/General.js"></script>
<script src="../../Scripts/JsTemplates/ContractSummaryNote.js"></script>
<div>
<uc1:ucProcessInfo ID="ucProcessInfo1" runat="server" />
</div>
<%-- <div style="float: right">
<uc2:ucGridActions ID="ucGridActions1" runat="server" />
</div>--%>
<br />
<div>
<table>
<thead class="gridHeader">
</thead>
</table>
<table>
<tr>
<td>
<div>
<input id="btnEdit" type="button" value="button" style="display: none; visibility: hidden;" runat="server" />
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>
</div>
<br />
</div>
</td>
</tr>
</table>
</div>
<asp:ModalPopupExtender ID="ModalPopupExtender1"
runat="server" CancelControlID="btnCancel"
OkControlID="btnOkay" TargetControlID="btnEdit"
PopupControlID="Panel1" PopupDragHandleControlID="PopupHeader"
Drag="true" BackgroundCssClass="DarkenBackground">
</asp:ModalPopupExtender>
<div class="popupConfirmation" id="Panel1" style="display: none">
<iframe id="frameeditexpanse" src="AddEdit.aspx" frameborder="0"></iframe>
<div class="popup_Buttons" style="display: none">
<input id="btnOkay" type="button" value="Done" />
<input id="btnCancel" type="button" value="Cancel" />
</div>
</div>
</asp:Content>
AddEdit.aspx
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AddEdit.aspx.cs" Inherits="TransitionAutomationPlatform.WebApp.Templates.ContractSummaryNote.AddEdit" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<link href="../../Content/jquery.dataTables.css" rel="stylesheet" />
<link href="../../Content/TableTools.css" rel="stylesheet" />
<script src="../../Scripts/General.js"></script>
<script src="../../Scripts/JsTemplates/ContractSummaryNote.js"></script>
<script type="text/javascript" src="../../Scripts/ZeroClipboard/ZeroClipboard.js"></script>
<script src="../../Scripts/jquery.dataTables.js"></script>
<script src="../../Scripts/dataTables.tableTools.js"></script>
<script src="../../Scripts/jquery-1.11.3.min.js"> </script>
<script src="../../Scripts/jquery-ui.min.js"></script>
<script src="../../Scripts/jquery.dataTables.min.js"></script>
<%--<script src="../../Scripts/dataTables.buttons.min.js"></script>--%>
<script src="../../Scripts/jquery-ui-1.11.3/jquery-ui-1.11.3/jquery-ui.js"></script>
<script src="../../Scripts/jquery-ui-1.11.3/jquery-ui-1.11.3/jquery-ui.js"></script>
<script src="../../Scripts/jquery-ui-1.11.3/jquery-ui-1.11.3/jquery-ui.min.js"></script>
<script src="../../Scripts/buttons.flash.min.js"></script>
<script src="../../Scripts/jszip.js"></script>
<script src="../../Scripts/jszip.min.js"></script>
<script src="../../Scripts/pdfmake.min.js"></script>
<script src="../../Scripts/vfs_fonts.js"></script>
<%--<script src="../../Scripts/dataTables.buttons.min.js"></script>--%>
<script src="../../Scripts/buttons.html5.min.js"></script>
<script src="../../Scripts/dataTables.editor.js"></script>
<div class="popup_Container">
<div class="popup_Titlebar" id="PopupHeader">
<div class="TitlebarLeft">
Edit Expanse
</div>
<div class="TitlebarRight" onclick="cancel();">
</div>
</div>
<div class="popup_Body">
<div id="dialog-message" title="Contract Summary Note Details">
<table>
<tr>
<td>
<table style="border-bottom: 1px solid #dadada;" class="ModalTable">
<tr>
<td>Document Name<span style="color: red;">*</span></td>
<td>
<input type="text" id="txtDocumentName" maxlength="50" /></td>
</tr>
<tr>
<td>Clause No<span style="color: red;">*</span></td>
<td>
<input type="text" id="txtClauseNo" maxlength="50" /></td>
</tr>
<tr>
<td>Page No <span style="color: red;">*</span></td>
<td>
<input type="text" id="txtPageNo" maxlength="50" /></td>
</tr>
<tr>
<td>Linl EPM Task<span style="color: red;">*</span></td>
<td>
<select name="ddlEPMTaskName" id="ddlEPMTaskName"></select>
<%-- Group Details--%>
</td>
</tr>
<tr>
<td>Due Date as per Project Plan</td>
<td>
<input type="text" id="txtDueDate" /></td>
</tr>
<tr>
<td>Function Name <span style="color: red;">*</span></td>
<td>
<select name="ddlFunctionName" id="ddlFunctionName"></select>
<%-- Group Details--%>
</td>
</tr>
<tr>
<td>Owner</td>
<td>
<input type="text" id="txtOwner" />
<tr>
<td>Activity at risk of missing Contracted Due Date</td>
<td>
<input type="checkbox" id="chkIsActivityAtRisk" value="" checked="checked" /></td>
</tr>
<tr>
<td>Status <span style="color: red;">*</span></td>
<td>
<select name="ddlStatus" id="ddlStatus"></select>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
edit data
</div>
<div class="popup_Buttons">
<input id="btnOkay" type="button" value="Done" runat="server" />
<input id="btnCancel" type="button" value="Cancel" />
</div>
</div>
</asp:Content>
<%-- Reference for Js file --%>

ruby selenium click on button with class name

I'm using ruby and selenium to test a web page, with the two buttons below
<div class="AVdis">
<span class="gwt-InlineHTML"/>
<a class="AVcur" name="attendEdit"; font-size: 12px;">[edit]</a>
</div>
<div class="lineHeight">
<button type="button" class="pcbtn" style="display: inline-block;">yes</button>
</div>
I've tried to use
driver.find_elements(:class, 'AVcur').click
driver.find_elements(:class, 'pcbtn').click
but it doesn't work, please advise.
Thanks
updated the full HTML code(the part code of class 'pcbtn' ONLY, it doesn't include the part with class 'AVcur'.):
<body>
<iframe src="javascript:'';" id="__gwt_historyFrame" style="width: 0px; height: 0px; border: 0px; display: block;"/>
<iframe src="javascript:''" id="Attend" tabindex="-1" style="position: absolute; width: 0px; height: 0px; border: none;"/>
<div style="display: none;"/>
<div class="GFKFO5SBPF hBody nClientFalse">
<div class="left" style="width: 198px;">
<div class="contents nClientFalse2">
<div class="AVright">
<div class="GFKFO5SBIQ">
<div class="AVfirstTd">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="left" style="vertical-align: top;">
<div>
<table cellpadding="0" cellspacing="0" class="pcattd_record" width="630px">
<tbody>
<tr class="GFKFO5SBCS">
<tr class="GFKFO5SBCS">
<th>
<td>
<table class="noborder">
<tbody>
<tr>
<td>
<td>
<div class="lineHeight">
<button type="button" class="pcbtn" style="display: inline-block;">press button</button>
Try to click it, using xpath:
driver.find_element(:xpath, "//div[#class='AVdis']//a[#name='attendEdit']").click
Second element xpath:
driver.find_element(:xpath, "//div[#class='lineHeight']//button[#class='pcbtn'][text()='yes']").click
Click an element:
driver.find_element(css: 'a').click

RadScheduler not working on MonthView

I want to show different content to the user depending on the view he is using. For that, i customized the AppointmentTemplate and the AppointmentCreated event. I want also to show appointments with dynamic height, meaning they expand to fill the content but on days its got nothing it shrinks.
Whats happening is that on MonthView, only the header is shown as in the photo:
And here is the DayView: photo
Here is the AppointmentCreated
protected void sched_AppointmentCreated(object sender, AppointmentCreatedEventArgs e) {
using (DBFactory link = new DBFactory()) {
int evtID = int.Parse(e.Appointment.ID.ToString());
if (evtID == 0) {
evtID = SessionManager.Instance.LastInsertedCalendarEventID;
}
CalendarEvent ce = link.GetCalendarEvent(evtID);
Label lblHeader = (Label)e.Container.FindControl("lblHeader");
Label lblDescription = (Label)e.Container.FindControl("lblDescription");
Label lbldates = (Label)e.Container.FindControl("lbldates");
Label lblParticipants = (Label)e.Container.FindControl("lblParticipants");
Label lblLocale = (Label)e.Container.FindControl("lbllocale");
switch (sched.SelectedView) {
case SchedulerViewType.DayView:
lblLocale.Text = string.Format("{0}", ce.EventLocation1.Location);
lblHeader.Text = string.Format("{0} - {1} ", ce.EventType1.EventTypeName, ce.Subject);
lblDescription.Text = string.Format("{0}", ce.Description);
lbldates.Text = string.Format("{0:hh:mm}h - {1:hh:mm}h", ce.StartDate, ce.EndDate);
lblParticipants.Text = string.Format("{0}", link.GetUsernamesFromEvent(evtID));
break;
case SchedulerViewType.WeekView:
case SchedulerViewType.MonthView:
lblLocale.Text = string.Format("{0}", ce.EventLocation1.Location);
lblHeader.Text = string.Format("{0} - {1} ", ce.EventType1.EventTypeName, ce.Subject);
lblDescription.Text = string.Format("{0}", ce.Description);
lbldates.Text = string.Format("{0:hh:mm}h - {1:hh:mm}h", ce.StartDate, ce.EndDate);
lblParticipants.Text = string.Format("{0}", link.GetInitialsFromEvent(evtID));
break;
}
}
}
and here is the complete markup
<tk:RadScheduler ID="sched" runat="server" AppointmentStyleMode="Default" DayEndTime="19:00:00" AllowInsert="true" AllowEdit="true" AllowDelete="true"
EnableDescriptionField="True" FirstDayOfWeek="Monday" LastDayOfWeek="Friday"
ShowNavigationPane="true" ShowFooter="False" StartEditingInAdvancedForm="true"
StartInsertingInAdvancedForm="true" Height="551px"
OnFormCreated="sched_FormCreated"
OnAppointmentCommand="sched_AppointmentCommand"
OnAppointmentCreated="sched_AppointmentCreated"
OnAppointmentDataBound="sched_AppointmentDataBound"
Skin="Web20">
<MonthView AdaptiveRowHeight="true" MinimumRowHeight="50" VisibleAppointmentsPerDay="30"/>
<AdvancedForm Modal="true" />
<ExportSettings OpenInNewWindow="true" FileName="SchedulerExport">
<Pdf PageTitle="Schedule" Author="Telerik" Creator="Telerik" Title="Schedule"></Pdf>
</ExportSettings>
<TimelineView UserSelectable="false" />
<AppointmentContextMenuSettings EnableDefault="true" />
<TimeSlotContextMenuSettings EnableDefault="true" />
<TimeSlotContextMenus>
<tk:RadSchedulerContextMenu ID="SchedulerTimeSlotContextMenu" runat="server">
<Items>
<tk:RadMenuItem Text="New Appointment" Value="CommandAddAppointment" />
</Items>
</tk:RadSchedulerContextMenu>
</TimeSlotContextMenus>
<AppointmentContextMenus>
<tk:RadSchedulerContextMenu runat="server" ID="ContextMenu1">
<Items>
<%--<tk:RadMenuItem Text="Ir para dia" Value="CommandNavigateDay" />--%>
<tk:RadMenuItem Text="Editar" Value="CommandEdit" />
<tk:RadMenuItem Text="Apagar" Value="CommandDelete" />
<%--<tk:RadMenuItem Text="Exportar Para PPF" Value="CommandExport"></tk:RadMenuItem>--%>
</Items>
</tk:RadSchedulerContextMenu>
</AppointmentContextMenus>
<AppointmentTemplate>
<asp:Label runat="server" ID="lblHeader" Font-Bold="true" />
<hr />
<table border="0">
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Descricao: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblDescription" runat="server" /></td>
</tr>
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Participantes: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblParticipants" runat="server" /></td>
</tr>
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Duracao: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblDates" runat="server" /></td>
</tr>
<tr>
<td style=" border-color:transparent;"><span style="font-weight:bold;">Local: </span></td>
<td style=" border-color:transparent;"><asp:Label ID="lblLocale" runat="server" /></td>
</tr>
</table>
</AppointmentTemplate>
<AdvancedInsertTemplate>
<div class="rsAdvancedEdit rsAdvancedModal" style="position: relative; margin-right: -100px">
<div class="rsModalBgTopLeft"></div>
<div class="rsModalBgTopRight"></div>
<div class="rsModalBgBottomLeft"></div>
<div class="rsModalBgBottomRight"></div>
<div class="rsAdvTitle">
<h1 class="rsAdvInnerTitle"><%# Container.Appointment.Owner.Localization.AdvancedNewAppointment %></h1>
<asp:LinkButton runat="server" ID="LinkButton1" CssClass="rsAdvEditClose"
CommandName="Cancel" CausesValidation="false" ToolTip='<%# Container.Appointment.Owner.Localization.AdvancedClose %>'>
<%# Container.Appointment.Owner.Localization.AdvancedClose%>
</asp:LinkButton>
</div>
<div class="rsAdvContentWrapper" style="background-color: #ffffff;">
<table border="0">
<tr>
<td>
<asp:Label runat="server" Text="Sumário" ID="lblSummaryHdr" /></td>
<td colspan="3">
<asp:TextBox ID="txtSubject" runat="server" CssClass="textbox" Columns="60" Text='<%# Bind("Subject") %>' /></td>
<td>
<asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ID") %>' Visible="false" /></td>
</tr>
<tr>
<td>Descrição</td>
<td colspan="3">
<asp:TextBox ID="txtDescription" CssClass="textbox" Columns="60" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox><br />
</td>
</tr>
<tr>
<td>Inicío</td>
<td>
<tk:RadDateTimePicker ID="startInput" SelectedDate='<%# Bind("Start") %>' runat="server"></tk:RadDateTimePicker>
</td>
<td>Fim</td>
<td>
<tk:RadDateTimePicker ID="finishInput" SelectedDate='<%# Bind("End") %>' runat="server"></tk:RadDateTimePicker>
</td>
</tr>
<tr>
<td>Tipo</td>
<td>
<tk:RadComboBox ID="ddlEventType" runat="server" CssClass="combo" />
</td>
<td>Sala</td>
<td>
<tk:RadComboBox ID="ddlLocations" runat="server" CssClass="combo" />
</td>
</tr>
<tr>
<td>Grupos</td>
<td>
<tk:RadComboBox ID="ddlGroups" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
<td>Usuários</td>
<td>
<tk:RadComboBox ID="ddlUsers" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
</tr>
</table>
<asp:Panel runat="server" ID="Panel1" CssClass="rsAdvancedSubmitArea">
<div class="rsAdvButtonWrapper">
<asp:LinkButton CommandName="Insert" runat="server" ID="LinkButton2" CssClass="rsAdvEditSave">
<span><%# Container.Appointment.Owner.Localization.Save%></span>
</asp:LinkButton>
<asp:LinkButton runat="server" ID="LinkButton3" CssClass="rsAdvEditCancel" CommandName="Cancel" CausesValidation="false">
<span><%# Container.Appointment.Owner.Localization.Cancel%></span>
</asp:LinkButton>
</div>
</asp:Panel>
</div>
</div>
</AdvancedInsertTemplate>
<AdvancedEditTemplate>
<div class="rsAdvancedEdit rsAdvancedModal" style="position: relative; margin-right: -100px">
<div class="rsModalBgTopLeft"></div>
<div class="rsModalBgTopRight"></div>
<div class="rsModalBgBottomLeft"></div>
<div class="rsModalBgBottomRight"></div>
<div class="rsAdvTitle">
<h1 class="rsAdvInnerTitle"><%# Container.Appointment.Owner.Localization.AdvancedEditAppointment %></h1>
<asp:LinkButton runat="server" ID="LinkButton4" CssClass="rsAdvEditClose"
CommandName="Cancel" CausesValidation="false" ToolTip='<%# Container.Appointment.Owner.Localization.AdvancedClose %>'>
<%# Container.Appointment.Owner.Localization.AdvancedClose%>
</asp:LinkButton>
</div>
<div class="rsAdvContentWrapper" style="background-color: #ffffff;">
<table>
<tr>
<td>Sumário</td>
<td colspan="3">
<asp:TextBox ID="txtSubject" runat="server" CssClass="textbox" Columns="60" Text='<%# Bind("Subject") %>' /></td>
</tr>
<tr>
<td>Descrição</td>
<td colspan="3">
<asp:TextBox ID="txtDescription" CssClass="textbox" Columns="60" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox><br />
</td>
</tr>
<tr>
<td>Inicío</td>
<td>
<tk:RadDateTimePicker ID="RadDateTimePicker1" SelectedDate='<%# Bind("Start") %>' runat="server"></tk:RadDateTimePicker>
</td>
<td>Fim</td>
<td>
<tk:RadDateTimePicker ID="RadDateTimePicker2" SelectedDate='<%# Bind("End") %>' runat="server"></tk:RadDateTimePicker>
</td>
</tr>
<tr>
<td>Tipo</td>
<td>
<tk:RadComboBox ID="RadComboBox1" runat="server" CssClass="combo" />
</td>
<td>Sala</td>
<td>
<tk:RadComboBox ID="ddlLocations" runat="server" CssClass="combo" />
</td>
</tr>
<tr>
<td>Grupos</td>
<td>
<tk:RadComboBox ID="RadComboBox3" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
<td>Usuários</td>
<td>
<tk:RadComboBox ID="RadComboBox4" runat="server" CssClass="combo" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" />
</td>
</tr>
<tr>
<td>Privado</td>
<td colspan="3">
<asp:CheckBox runat="server" ID="CheckBox1" AutoPostBack="false" Checked="false" />
</td>
</tr>
</table>
<asp:Panel runat="server" ID="Panel2" CssClass="rsAdvancedSubmitArea">
<div class="rsAdvButtonWrapper">
<asp:LinkButton CommandName="Update" runat="server" ID="LinkButton5" CssClass="rsAdvEditSave">
<span><%# Container.Appointment.Owner.Localization.Save%></span>
</asp:LinkButton>
<asp:LinkButton runat="server" ID="LinkButton6" CssClass="rsAdvEditCancel" CommandName="Cancel" CausesValidation="false">
<span><%# Container.Appointment.Owner.Localization.Cancel%></span>
</asp:LinkButton>
</div>
</asp:Panel>
</div>
</div>
</AdvancedEditTemplate>
</tk:RadScheduler>
There is a KB article on this found on the telerik site:
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/auto-expand-the-height-of-the-appointment.aspx

MVC form doesn't validate

I am very new to MVC 3.
I am using custom helpers for the controls but when i submit the form, the control is not being validated.
Can some one tell me if i am missing something? Following is the code snippet.
public static MvcHtmlString TextBox(string fieldName)
{
TagBuilder tagBuilder = new TagBuilder("Input");
tagBuilder.MergeAttribute("type", "Text");
tagBuilder.AddCssClass("text-box");
tagbuilder.MergeAttribute("data-val","true");
tagbuilder.MergeAttribute("data-val-regex-pattern","true");
tagbuilder.MergeAttribute("data-val","true");
TagBuilder validator = new TagBuilder("span");
validator.MergeAttribute("data-valmsg-for", fieldName);
validator.MergeAttribute("data-valmsg-replace", "true");
validator.MergeAttribute("class", "field-validation-valid");
return new MvcHtmlString(string.Concat(tagBuilder.ToString(), validator.ToString()));
}
The view has the following code
#using (Html.BeginForm())
{
#Html.ValidationSummary(true)
<div class="main-border" style="width: 890px;">
<div style="clear: both;">
</div>
<div style="padding: 0px 20px 0px 20px;">
<table style="width: 100%">
<tr>
<td colspan="2" class="main-subhead2">
<div class="label-text">
</div>
</td>
</tr>
<tr>
<td>Email :</td>
<td>#ControlHelper.TextBox("txtEmailAddress")</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="submit" onclick="return validate(this.form);" /></td>
</tr>
</table>
</div>
</div>
}
the source code of rendered by the page is :
<form action="/" method="post">
<div class="main-border" style="width: 890px;">
<div style="clear: both;">
</div>
<div style="padding: 0px 20px 0px 20px;">
<table style="width: 100%">
<tr>
<td colspan="2" class="main-subhead2">
<div class="label-text">
</div>
</td>
</tr>
<tr>
<td>Email :</td>
<td><Input class="text-box" data-val="True" data-val-regex-pattern="^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z]))*#[A-Za-z0-9_\.-]+[A-Za-z0-9_][A-Za-z0-9_]$" name="txtEmailAddress" type="Text" visible="True"></Input><span class="field-validation-valid" data-valmsg-for="txtEmailAddress" data-valmsg-replace="true"></span></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="submit" /></td>
</tr>
</table>
</div>
</div>
</form>
Input should be lowercased:
TagBuilder tagBuilder = new TagBuilder("input");
And don't forget to include the unobtrusive client side validation scripts to your page:
<script src="#Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
and ensure that client side validation is enabled in web.config:
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
There are a number of reasons your form may not validating. In MVC3, you're most likely going to want to use unobtrusive validation (via jQuery). You can learn how to do this (it's not a big change - just include the correct JavaScript libraries and update web.config) at Microsoft's ASP.NET website.
You may need to add (data-val-regex) attribute:
public static MvcHtmlString TextBox(string fieldName)
{
TagBuilder tagBuilder = new TagBuilder("Input");
tagBuilder.MergeAttribute("type", "Text");
tagBuilder.AddCssClass("text-box");
tagbuilder.MergeAttribute("data-val","true");
tagbuilder.MergeAttribute("data-val-regex-pattern","true");
tagbuilder.MergeAttribute("data-val","true");
tagbuilder.MergeAttribute("data-val-regex","Field must be character (?![ء|ئ|ؤ])[ء-يA-Za-z]");
TagBuilder validator = new TagBuilder("span");
validator.MergeAttribute("data-valmsg-for", fieldName);
validator.MergeAttribute("data-valmsg-replace", "true");
validator.MergeAttribute("class", "This is an invalid Email format!");
return new MvcHtmlString(string.Concat(tagBuilder.ToString(), validator.ToString()));
}

Resources