Search Results

Search found 83 results on 4 pages for 'requiredfieldvalidator'.

Page 3/4 | < Previous Page | 1 2 3 4  | Next Page >

  • How do you reenable a validation control w/o it simultaneously perform an immediate validation?

    - by Velika2
    When I called this function to enable a validator from client javascript: `ValidatorEnable(document.getElementById('<%=valPassportOtherText.ClientID%>'), true); //enable` validation control the required validation control immediately performed it validation, found the value in the associated text box blank and set focus to the textbox (because SetFocusOnError was set to true). As a result, the side effect was that focus was shifted to the control that was associated with the Validation control, i teh example, txtSpecifyOccupation. <asp:TextBox ID="txtSpecifyOccupation" runat="server" AutoCompleteType="Disabled" CssClass="DefaultTextBox DefaultWidth" MaxLength="24" Rows="2"></asp:TextBox> <asp:RequiredFieldValidator ID="valSpecifyOccupation" runat="server" ControlToValidate="txtSpecifyOccupation" ErrorMessage="1.14b Please specify your &lt;b&gt;Occupation&lt;/b&gt;" SetFocusOnError="True">&nbsp;Required</asp:RequiredFieldValidator> Perhaps there is a way to enable the (required) validator without having it simultaneously perform the validation (at least until the user has tabbed off of it?) I'd like validation of the txtSpecifyOccupation textbox to occur only on a Page submit or when the user has tabbed of the required txtSpecifyoccupation textbox. How can I achieve this?

    Read the article

  • ASP.NET enum dropdownlist validation

    - by Arun Kumar
    I have got a enum public enum TypeDesc { [Description("Please Specify")] PleaseSpecify, Auckland, Wellington, [Description("Palmerston North")] PalmerstonNorth, Christchurch } I am binding this enum to drop down list using the following code on page_Load protected void Page_Load(object sender, EventArgs e) { if (TypeDropDownList.Items.Count == 0) { foreach (TypeDesc newPatient in EnumToDropDown.EnumToList<TypeDesc>()) { TypeDropDownList.Items.Add(EnumToDropDown.GetEnumDescription(newPatient)); } } } public static string GetEnumDescription(Enum value) { FieldInfo fi = value.GetType().GetField(value.ToString()); DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes != null && attributes.Length > 0) return attributes[0].Description; else return value.ToString(); } public static IEnumerable<T> EnumToList<T>() { Type enumType = typeof(T); // Can't use generic type constraints on value types, // so have to do check like this if (enumType.BaseType != typeof(Enum)) throw new ArgumentException("T must be of type System.Enum"); Array enumValArray = Enum.GetValues(enumType); List<T> enumValList = new List<T>(enumValArray.Length); foreach (int val in enumValArray) { enumValList.Add((T)Enum.Parse(enumType, val.ToString())); } return enumValList; } and my aspx page use the following code to validate <asp:DropDownList ID="TypeDropDownList" runat="server" > </asp:DropDownList> <asp:RequiredFieldValidator ID="TypeRequiredValidator" runat="server" ControlToValidate="TypeDropDownList" ErrorMessage="Please Select a City" Text="<img src='Styles/images/Exclamation.gif' />" ValidationGroup="city"></asp:RequiredFieldValidator> But my validation is accepting "Please Specify" as city name. I want to stop user to submit if the city is not selected.

    Read the article

  • asp.net CustomValidator never fires OnServerValidate

    - by Bryce Fischer
    I have the following ASP page: <asp:Content ID="Content2" ContentPlaceHolderID="ShellContent" runat="server"> <form runat="server" id="AddNewNoteForm" method="post""> <fieldset id="NoteContainer"> <legend>Add New Note</legend> <asp:ValidationSummary ID="ValidationSummary1" runat="server" /> <div class="ctrlHolder"> <asp:Label ID="LabelNoteDate" runat="server" Text="Note Date" AssociatedControlID="NoteDateTextBox"></asp:Label> <asp:TextBox ID="NoteDateTextBox" runat="server" class="textInput" CausesValidation="True" ></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" ControlToValidate="NoteDateTextBox" OnServerValidate="CustomValidator1_ServerValidate" Display="Dynamic" >*</asp:CustomValidator> </div> <div class="ctrlHolder"> <asp:Label ID="LabelNoteText" AssociatedControlID="NoteTextTextBox" runat="server" Text="Note"></asp:Label> <asp:TextBox ID="NoteTextTextBox" runat="server" Height="102px" TextMode="MultiLine" class="textInput" ></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Note Text is Required" ControlToValidate="NoteTextTextBox">*</asp:RequiredFieldValidator> </div> <div class="buttonHolder"> <asp:Button ID="OkButton" runat="server" Text="Add New Note" CssClass="primaryAction" onclick="OkButton_Click"/> <asp:HyperLink ID="HyperLink1" runat="server">Cancel</asp:HyperLink> </div> </fieldset> </form> </asp:Content> and the following code behind for the CustomValidator1_ServerValidate() method: protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) { if (string.IsNullOrEmpty(args.Value.Trim())) { args.IsValid = false; CustomValidator1.ErrorMessage = "Note Date is Required!"; return; } DateTime testDate; if (DateTime.TryParse(args.Value, out testDate)) { args.IsValid = true; CustomValidator1.ErrorMessage = "Invalid Date!"; } } It never seems to fail validation no matter what I put in the text box... Should mention this is ASP.NET 2.0

    Read the article

  • ValidatorCallout(asp.net ajax) and CheckListBox

    - by TJ
    Hi, Just wondering if anyone has a good solution to utlise ValidatorCallout with a CheckListBox ? The only solution I could see was creating a custom RequiredFieldValidator as per http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2Ftips%2Ft040302-1.shtml. If anyone has any good solution, it would be appreciated if you could share it. thanks

    Read the article

  • Add special characters to Asp.net RegularExpressionValidator for E-Mail

    - by Hasan Gürsoy
    I have a e-mail address validator but I need to add special characters as valid for example ü, ç... Because users in Turkey (or anywhere else) can have a web site url like: hasangürsoy.com My code is below: <asp:TextBox ID="tEMail" runat="server" /> <asp:RequiredFieldValidator ID="rfvEMail" runat="server" ControlToValidate="tEMail" ErrorMessage="* required" /> <asp:RegularExpressionValidator ID="revEMail" runat="server" ControlToValidate="tEMail" ErrorMessage="* invalid" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />

    Read the article

  • LinkButton not working due to validation control field

    - by Alexander
    In my .aspx page which derives from a master page I have a contact form which uses some validation, such as the RequiredFieldValidator and RegularExpressValidator. At top of my page I have a link bar and whenver I am at contact.aspx I can't navigate to the other pages as if that I need to fill in the necessary data so that it satisfies the validator. How can I fix this?

    Read the article

  • ASP.Net - validating email address with regexp?

    - by ElHaix
    When validating an email address with the regex validation component, an additional RequiredFieldValidator must be added to ensure there is a value present. I've mostly taken care of this with a CustomFieldValidator, and taking care of this with Javascript. Is there a better way of doing this?

    Read the article

  • Jquery datepicker popup not closing on select date in IE8

    - by Notorious2tall
    I've got a web form with a start date field. I've tied a jquery datepicker to the txt field. Now when I choose a date in FF, the selected date is populated in the text box and the calendar popup closes. However when I do the same thing in IE8, the selected date is populated in the text box but the popup remains open. I've also noticed that a script error is generated as soon as I select a date in the popup calendar. I'm using jquery 1.3.2, jquery-ui 1.7.2, and .NET 3.5. Here's an example of my code: <script type="text/javascript"> $(document).ready(function() { $("#<%=txtStartDate.ClientID%>").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOn: 'button', buttonImage: '/_layouts/images/CALENDAR.GIF', buttonImageOnly: true }); }); </script> <div id="stylized"> <asp:ValidationSummary ID="vs" runat="server" CssClass="messages-error" HeaderText=" Action required before the form can be submitted." ForeColor="" ValidationGroup="sh" /> <div class="formrow"> <div class="ms-formlabel formlabel"> <asp:Label ID="lblStartDate" runat="server" CssClass="ms-standardheader" AssociatedControlID="txtStartDate">Start Date:</asp:Label> </div> <div class="ms-formbody formfield"> <asp:RequiredFieldValidator ID="reqStartDate" runat="server" ControlToValidate="txtStartDate" ErrorMessage="Start Date is a required field." Text="*" Display="Dynamic" ValidationGroup="sh"></asp:RequiredFieldValidator> <asp:CompareValidator ID="cvStartDate" runat="server" ControlToValidate="txtStartDate" ErrorMessage="Date must be in the format MM/DD/YYYY" Text="*" Display="Dynamic" ValidationGroup="sh" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator> <asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox> <span class="formMessage">ex. MM/DD/YYYY</span> </div> </div> <div id="buttonrow"> <asp:Button ID="btnSubmit" runat="server" Text="Submit" CssClass="ms-ButtonHeightWidth" OnClick="Submit_Click" ValidationGroup="sh" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="ms-ButtonHeightWidth" OnClick="Cancel_Click" CausesValidation="false" /> </div> </div> Here's the script error I get in IE when I select the date: 'length' is null or not an object WebResource.axd Here's the code where the error is being thrown from: function ValidatorOnChange(event) { if (!event) { event = window.event; } Page_InvalidControlToBeFocused = null; var targetedControl; if ((typeof(event.srcElement) != "undefined") && (event.srcElement != null)) { targetedControl = event.srcElement; } else { targetedControl = event.target; } var vals; if (typeof(targetedControl.Validators) != "undefined") { vals = targetedControl.Validators; } else { if (targetedControl.tagName.toLowerCase() == "label") { targetedControl = document.getElementById(targetedControl.htmlFor); vals = targetedControl.Validators; } } var i; for (i = 0; i < vals.length; i++) { ValidatorValidate(vals[i], null, event); } ValidatorUpdateIsValid(); } It happens on the .length in the for loop at the end. Vals is null and isn't found in the previous if/else. I've stepped through the javascript and if (typeof(targetedControl.Validators) != "undefined") returns false and then if (targetedControl.tagName.toLowerCase() == "label") returns false too. Thus the length is null or not an object error. Now I'm not sure if the datepicker popup not closing in IE and the script error in the WebResources.axd file are related errors, but I'm leaning that way. Can anyone tell me why the popup isn't closing?

    Read the article

  • ModalPopupExtender and validation problems

    - by Malachi
    The problem I am facing is that when there is validation on a page and I am trying to display a model pop-up, the pop-up is not getting displayed. And by using fire-bug I have noticed that an error is being thrown. The button that is used to display the pop-up has cause validation set to false so I am stuck as to what is causing the error. I have created a sample page to isolate the problem that I am having, any help would be greatly appreciated. The Error function () {Array.remove(Page_ValidationSummaries, document.getElementById("ValidationSummary1"));}(function () {var fn = function () {AjaxControlToolkit.ModalPopupBehavior.invokeViaServer("mpeSelectClient", true);Sys.Application.remove_load(fn);};Sys.Application.add_load(fn);}) is not a function http://localhost:1131/WebForm1.aspx Line 136 ASP <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CLIck10.WebForm1" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <asp:Button ID="btnPush" runat="server" Text="Push" CausesValidation="false" onclick="btnPush_Click" /> <asp:TextBox ID="txtVal" runat="server" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtVal" ErrorMessage="RequiredFieldValidator" /> <asp:ValidationSummary ID="ValidationSummary1" runat="server" /> <asp:Panel ID="pnlSelectClient" Style="display: none" CssClass="box" runat="server"> <asp:UpdatePanel ID="upnlSelectClient" runat="server"> <ContentTemplate> <asp:Button ID="btnOK" runat="server" UseSubmitBehavior="true" Text="OK" CausesValidation="false" OnClick="btnOK_Click" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancel_Click" /> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> <input id="popupDummy" runat="server" style="display:none" /> <ajaxToolkit:ModalPopupExtender ID="mpeSelectClient" runat="server" TargetControlID="popupDummy" PopupControlID="pnlSelectClient" OkControlID="popupDummy" BackgroundCssClass="modalBackground" CancelControlID="btnCancel" DropShadow="true" /> </div> </form> Code Behind using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CLIck10 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnOK_Click(object sender, EventArgs e) { mpeSelectClient.Hide(); } protected void btnCancel_Click(object sender, EventArgs e) { mpeSelectClient.Hide(); } protected void btnPush_Click(object sender, EventArgs e) { mpeSelectClient.Show(); } } }

    Read the article

  • ModalPopupExtender z-index value decreases after every show

    - by ryanulit
    This is a new one I have never seen before. I have a gridview containing a bunch of categories that can be edited by clicking on the respective "Edit" link within the gridview. The modalpopupextender is then shown programmatically (.show() method) and the user is allowed to edit the category. Then the modal popup is programmtically hidden (.hide() method) when the user presses "Update" or "Cancel". For some reason after every new show of the modal popup, the z-index is decreasing by 1000 until it is hidden behind everything on my page. It starts at 7000 for the very first show. Therefore the user would not be able to edit an infinite number of categories if they wanted to. Any ideas why this is happening? Css class used on modalpopupextender: DIV.box-pop { border: #95aab9 1px solid; background-color: #ECF1F5; display: block; position: relative; margin: -6px 6px 6px -6px; padding: 4px; z-index: 10000; } Panel used for popup: <asp:Panel ID="PanelModify" runat="server" Width="250px" CssClass="box-pop"> <asp:UpdatePanel ID="UpdatePanelModify" runat="server" UpdateMode="Conditional"> <ContentTemplate> <table width="100%" cellpadding="3" cellspacing="3"> <tr> <td> <div class="box"> <h1> <span><strong> <asp:Literal ID="LiteralModalTitle" runat="server" /></strong></span> </h1> <table border="0" width="100%"> <tr> <td> <asp:TextBox ID="TextBoxModifiedText" runat="server" Width="173px" ValidationGroup="Modify"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidatorModifiedText" runat="server" ValidationGroup="Modify" ErrorMessage="*" ControlToValidate="TextBoxModifiedText" Display="Dynamic"> </asp:RequiredFieldValidator> </td> </tr> <tr> <td> <asp:Button ID="ButtonUpdate" runat="server" Text="Update" ValidationGroup="Modify" /><asp:Button ID="ButtonInsert" runat="server" Text="Insert" ValidationGroup="Modify" /> &nbsp; <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" CausesValidation="false" /> </td> </tr> </table> </div> </td> </tr> </table> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderModify" runat="server" PopupControlID="PanelModify" TargetControlID="ButtonHideModify" BackgroundCssClass="modalBackground"> </ajaxToolkit:ModalPopupExtender> <asp:Button ID="ButtonHideModify" runat="server" Style="display: none;" />

    Read the article

  • Can overlay work with a portion of a page that has codebehind functionallity?

    - by rolando
    i have a complete DIV in wich a have a gridview and a multiview with codebehind action: <cc3:CRDataSource EnableViewState="true" ID="DsOpciones" runat="server" SQLSelect="CartelElectronico,OpcionSeleccion_Todos"> <Parameters> <asp:QueryStringParameter Name="@FactorEvaluacionId" QueryStringField="FactorEvaluacionId" Type="String" /> </Parameters> </cc3:CRDataSource> <cc3:CRGridView ID="gvTipoFactorSeleccion" runat="server" DataKeyNames="OpcionSeleccionID" AllowPaging="false" AllowSorting="False" AutoGenerateColumns="False" Titulo="Opciones de Factor de Evaluacion" NoRowsMsg="No se encontraron Opciones para el factor de evaluación" CssClass="Table" AllowExport="False" AllowFilter="False" AllowCollapse="True" EnableViewState="False" PageSize="1000000000" DataSourceID="DsOpciones" OnRowUpdating="gvTipoFactorSeleccion_RowUpdating" OnRowDeleting="gvTipoFactorSeleccion_RowDeleting"> <Columns> <asp:BoundField DataField="Nombre" HeaderText="Nombre" SortExpression="Nombre" ItemStyle-HorizontalAlign="Left" /> <asp:BoundField DataField="Puntos" HeaderText="Puntos" ItemStyle-HorizontalAlign="Center" /> <asp:CommandField ButtonType="Link" ShowDeleteButton="true" DeleteText="Eliminar" ShowEditButton="true" EditText="Modificar" UpdateText="Actualizar" CancelText="Cancelar" /> <asp:TemplateField Visible="false"> <ItemTemplate> </ItemTemplate> </asp:TemplateField> </Columns> </cc3:CRGridView> <br /> <table> <tr valign="baseline"> <td class="contratacionTablaSubrayadoTitulosLineas"> <label class="contratacionEtiquetas"> Opción&nbsp;(*) :</label> </td> <td class="contratacionTablaSubrayadoContenidoLineas"> <asp:TextBox ID="tbOpcion" runat="server" ToolTip="Nombre del Factor de la metodología de evaluación" TabIndex="1" MaxLength="100"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="tbOpcion" ErrorMessage="&nbsp;Debe digitar un nombre para la Opción" Display="Dynamic" CssClass="inlineError" ValidationGroup="InsertarTipoFactorSeleccion" SetFocusOnError="false"></asp:RequiredFieldValidator> </td> </tr> <tr valign="baseline"> <td colspan="2" align="right"> <asp:LinkButton ID="LinkButton1" runat="server" CssClass="contratacionVinculos" ValidationGroup="InsertarTipoFactorSeleccion" OnClick="lbInsertarTipoFactorSeleccion_Click">Insertar</asp:LinkButton>&nbsp;|&nbsp; <asp:LinkButton ID="LinkButton2" runat="server" OnClick="lbCancelarInsertarTipoFactorSeleccion_Click" CssClass="contratacionVinculos" CausesValidation="false">Cancelar</asp:LinkButton> .... Thats just a portion of the div, my question is How can I show that DIV in a jquery overlay without loosing its functionallity? i'm asking because i manage to get it working but when i do a "that-div-postback" the screen loses the DIV and keeps only the background of the overlay. a couple more information: <button class="modalInput button" rel="#prompt"> Buscar</button> <script type="text/javascript"> function pageLoad() { var triggers = $("button.modalInput").overlay({ // some expose tweaks suitable for modal dialogs expose: { color: '#333', loadSpeed: 200, opacity: 0.3, zIndex: 99 }, top: '25%', closeOnClick: true }); } </script> Thanks in advance ;)

    Read the article

  • Trying to convert string to datetime

    - by user1596472
    I am trying to restrict a user from entering a new record if the date requested already exits. I was trying to do a count to see if the table that the record would be placed in already has that date 1 or not 0. I have a calendar extender attached to a text box which has the date. I keep getting either a: String was not recognized as a valid DateTime. or Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'System.IConvertible'. depending on the different things I have tried. Here is my code. TextBox startd = (TextBox)(DetailsView1.FindControl("TextBox5")); TextBox endd = (TextBox)(DetailsView1.FindControl("TextBox7")); DropDownList lvtype = (DropDownList)(DetailsView1.FindControl("DropDownList6")); DateTime scheduledDate = DateTime.ParseExact(startd.Text, "dd/MM/yyyy", null); DateTime endDate = DateTime.ParseExact(endd.Text, "dd/MM/yyyy", null); DateTime newstartDate = Convert.ToDateTime(startd.Text); DateTime newendDate = Convert.ToDateTime(endd.Text); //foreach (DataRow row in sd.Tables[0].Rows) DateTime dt = newstartDate; while (dt <= newendDate) { //for retreiving from table Decimal sd = SelectCountDate(dt, lvtype.SelectedValue, countDate); String ndt = Convert.ToDateTime(dt).ToShortDateString(); // //start = string.CompareOrdinal(scheduledDate, ndt); // // end = string.CompareOrdinal(endDate, ndt); //trying to make say when leavetpe is greater than count 1 then throw error. if (sd > 0) { Response.Write("<script>alert('Date Already Requested');</script>"); } dt.AddDays(1); } ^^^ This version throws the: "String was not recognized as valid date type" error But if i replace the string with either of these : /*-----------------------Original------------------------------------ string scheduledDate = Convert.ToDateTime(endd).ToShortDateString(); string endDate = Convert.ToDateTime(endd).ToShortDateString(); -------------------------------------------------------------------*/ /*----------10-30--------------------------------------- DateTime scheduledDate = DateTime.Parse(startd.Text); DateTime endDate = DateTime.Parse(endd.Text); ------------------------------------------------------*/ I get the "Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'System.IConvertible'." error. I am just trying to stop a user from entering a record date that already exits. <InsertItemTemplate> <asp:TextBox ID="TextBox5" runat="server" Height="19px" Text='<%# Bind("lstdate", "{0:MM/dd/yyyy}") %>' Width="67px"></asp:TextBox> <asp:CalendarExtender ID="TextBox5_CalendarExtender" runat="server" Enabled="True" TargetControlID="TextBox5"> </asp:CalendarExtender> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox5" ErrorMessage="*Leave Date Required" ForeColor="Red"></asp:RequiredFieldValidator> <br /> <asp:CompareValidator ID="CompareValidator18" runat="server" ControlToCompare="TextBox7" ControlToValidate="TextBox5" ErrorMessage="Leave date cannot be after start date" ForeColor="Red" Operator="LessThanEqual" ToolTip="Must choose start date before end date"></asp:CompareValidator> </InsertItemTemplate>

    Read the article

  • ASP.NET Validator Controls Slowing Down Page

    - by Calvin Nguyen
    Hi all, I have an UpdatePanel that has user controls dynamically added to it. There can be a few dozen user controls at times. The page / UpdatePanel slows down big time on each postback as more user controls are added. After some digging, I was surprised to find the cause is the various CompareValidator, CustomValidator, RegularExpressionValidator and RequiredFieldValidator controls that exist on each user control. Dose anyone have suggestions? It strikes me as very peculiar that inclusion of these ASP.NET controls could have such a horrible effect on performance. Thanks, Calvin

    Read the article

  • How to disable listbox's click event

    - by StupidDeveloper
    I have a listbox which acts as a list of items. If you click on some item, it's contents are shown in the panel on the right (few textboxes etc.). I need to have a validation on these controls as all of them are required fields. And I do have it. The problem is that, even when the validators are not valid, user can click the listbox and change active index (that doesn't have impact on the panel on the right, as SelectedIndexChanged isn't fired). The validators are standard RequiredFieldValidator with their Display property set to "Dynamic". So, what I want is to disallow the user clicking on the listbox and changing the index untill all validators are Valid. What would be your solution for that? Is that even possible?

    Read the article

  • How to use client side code in Visual studio ASP.NET

    - by Robert
    I am a quite new to web development and I am trying to do some small form updates without causing a postback. For example making a control visible when a drop down list is changed. I have so far come across some features that achieve this like the RequiredFieldValidator inside an update panels. However, these are specific to a single task. What are my options to achieve these client side updates in Visual Studio? At the moment I don't know any JavaScript, so I would prefer another solution if it exists.

    Read the article

  • How to add/remove rows using SlickGrid

    - by lkahtz
    How to write such functions and bind them to two buttons like "add row" and "remove row": The now working example code only support adding new row by editing on the blank bottom line. <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>SlickGrid example 3: Editing</title> <link rel="stylesheet" href="../slick.grid.css" type="text/css"/> <link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.16.custom.css" type="text/css"/> <link rel="stylesheet" href="examples.css" type="text/css"/> <style> .cell-title { font-weight: bold; } .cell-effort-driven { text-align: center; } </style> </head> <body> <div style="position:relative"> <div style="width:600px;"> <div id="myGrid" style="width:100%;height:500px;"></div> </div> <div class="options-panel"> <h2>Demonstrates:</h2> <ul> <li>adding basic keyboard navigation and editing</li> <li>custom editors and validators</li> <li>auto-edit settings</li> </ul> <h2>Options:</h2> <button onclick="grid.setOptions({autoEdit:true})">Auto-edit ON</button> &nbsp; <button onclick="grid.setOptions({autoEdit:false})">Auto-edit OFF</button> </div> </div> <script src="../lib/firebugx.js"></script> <script src="../lib/jquery-1.7.min.js"></script> <script src="../lib/jquery-ui-1.8.16.custom.min.js"></script> <script src="../lib/jquery.event.drag-2.0.min.js"></script> <script src="../slick.core.js"></script> <script src="../plugins/slick.cellrangedecorator.js"></script> <script src="../plugins/slick.cellrangeselector.js"></script> <script src="../plugins/slick.cellselectionmodel.js"></script> <script src="../slick.formatters.js"></script> <script src="../slick.editors.js"></script> <script src="../slick.grid.js"></script> <script> function requiredFieldValidator(value) { if (value == null || value == undefined || !value.length) { return {valid: false, msg: "This is a required field"}; } else { return {valid: true, msg: null}; } } var grid; var data = []; var columns = [ {id: "title", name: "Title", field: "title", width: 120, cssClass: "cell-title", editor: Slick.Editors.Text, validator: requiredFieldValidator}, {id: "desc", name: "Description", field: "description", width: 100, editor: Slick.Editors.LongText}, {id: "duration", name: "Duration", field: "duration", editor: Slick.Editors.Text}, {id: "%", name: "% Complete", field: "percentComplete", width: 80, resizable: false, formatter: Slick.Formatters.PercentCompleteBar, editor: Slick.Editors.PercentComplete}, {id: "start", name: "Start", field: "start", minWidth: 60, editor: Slick.Editors.Date}, {id: "finish", name: "Finish", field: "finish", minWidth: 60, editor: Slick.Editors.Date}, {id: "effort-driven", name: "Effort Driven", width: 80, minWidth: 20, maxWidth: 80, cssClass: "cell-effort-driven", field: "effortDriven", formatter: Slick.Formatters.Checkmark, editor: Slick.Editors.Checkbox} ]; var options = { editable: true, enableAddRow: true, enableCellNavigation: true, asyncEditorLoading: false, autoEdit: false }; $(function () { for (var i = 0; i < 500; i++) { var d = (data[i] = {}); d["title"] = "Task " + i; d["description"] = "This is a sample task description.\n It can be multiline"; d["duration"] = "5 days"; d["percentComplete"] = Math.round(Math.random() * 100); d["start"] = "01/01/2009"; d["finish"] = "01/05/2009"; d["effortDriven"] = (i % 5 == 0); } grid = new Slick.Grid("#myGrid", data, columns, options); grid.setSelectionModel(new Slick.CellSelectionModel()); grid.onAddNewRow.subscribe(function (e, args) { var item = args.item; grid.invalidateRow(data.length); data.push(item); grid.updateRowCount(); grid.render(); }); }) </script> </body> </html>

    Read the article

  • customvalidator onServerValidate not firing

    - by Jamie
    I have a Radio button List and Text Box both with validation. <asp:RadioButtonList ID="member" runat="server" RepeatDirection="Horizontal"> <asp:ListItem>Yes</asp:ListItem> <asp:ListItem>No</asp:ListItem> </asp:RadioButtonList> <asp:requiredfieldvalidator id="unionvalidator" runat="server" controltovalidate="member" errormessage="Required" /> Required if member == "yes" <asp:TextBox runat="server" ID="union"></asp:TextBox> <asp:customvalidator ID="Customvalidator1" runat="server" ValidateEmptyText="true" onServerValidate="UnionValidate" errormessage="Your current union is required" /> My ServerValidate which doesn't fire at all. public void UnionValidate(object source, ServerValidateEventArgs args) { if (member.Text == "yes" && union.Text.Trim() == "") args.IsValid = false; }

    Read the article

  • asp:Validator in invisible elements + invisible targets

    - by Richard Neil Ilagan
    Somewhat straightforward: will asp:Validators still perform validation when they're in invisible containers? How about if their ControlToValidate target is invisible? For example: <asp:Panel id="myPanel" runat="server" visible="false"> <asp:Textbox id="myTextbox" runat="server" /> <asp:RequiredFieldValidator id="myRfv" runat="server" controltovalidate="myTextbox" /> </asp:Panel> Above is a Validator in an invisible Panel. Would myRfv still perform validation? How about if myTextbox is invisible instead? I'm asking this because I have very specialized Validators in my ASPX, wherein I also have Panels which are hidden/shown dynamically. While I'm all for disabling the validators themselves, I'm just curious whether they'll automatically disable anyway. Thanks guys! :D

    Read the article

  • how to find datakeys in oncheckedchanged event ?

    - by subodh
    <asp:Panel ID="pnlFocusAreaPanel" runat="server" GroupingText="Focus Area" Width="800"> <table cellspacing="0" cellpadding="0" width="750"> <tr> <td> <asp:GridView ID="dgFocusAreaDetails" runat="server" Width="100%" CssClass="dgStyle" AutoGenerateColumns="False" BorderColor="Silver" BorderWidth="1px" CellPadding="0" ShowHeader="False" OnSelectedIndexChanged="dgFocusAreaDetails_SelectedIndexChanged" DataKeyNames="PK_ID"> <FooterStyle Font-Underline="True" HorizontalAlign="Center" VerticalAlign="Middle"> </FooterStyle> <Columns> <asp:TemplateField HeaderText="Focus Area" HeaderStyle-BackColor="Silver"> <ItemStyle Width="90%" /> <ItemTemplate> <asp:Label runat="server" ID="lblFocusArea" Text='<%# DataBinder.Eval(Container.DataItem, "FOCUS_AREA_NAME").ToString()%>'> </asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Is Current Valid" HeaderStyle-BackColor="Silver"> <ItemStyle Width="10%" HorizontalAlign="Center" /> <ItemTemplate> <asp:CheckBox ID="chkFocusArea" runat="server" OnCheckedChanged="OnCheckChangedEvent" AutoPostBack="true" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </td> </tr> <tr> <td align="left"> <asp:TextBox ID="txtFocusArea" runat="server" Width="300px" CausesValidation="true" CssClass="txtStyle" ValidationGroup="focusArea"> </asp:TextBox> <cc1:TextBoxWatermarkExtender ID="txtFocusAreaWaterMark" runat="server" TargetControlID="txtFocusArea" WatermarkText="Add Focus Area" WatermarkCssClass="WaterMarkStyle"> </cc1:TextBoxWatermarkExtender> <asp:Button ID="btnAddFocusArea" runat="server" Text="AddFocusArea" CssClass="btnStyle" OnClick="btnAddFocusArea_Click" CausesValidation="true" ValidationGroup="focusArea" /> <asp:RequiredFieldValidator ID="reqtxtFocusArea" runat="server" ControlToValidate="txtFocusArea" ErrorMessage="Please enter focus area" Display="Dynamic" ValidationGroup="focusArea"> </asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="regexFocusArea" runat="server" ErrorMessage="Invalid characters(<,>,#)" ControlToValidate="txtFocusArea" ValidationExpression="^([^&lt;#&gt;]*)$" ValidationGroup="focusArea" Display="Dynamic" SetFocusOnError="true"> </asp:RegularExpressionValidator> </td> </tr> </table> </asp:Panel> and in code behind protected void btnAddFocusArea_Click(object sender, EventArgs e) { string strFocusArea = txtFocusArea.Text; OleDbConnection myConnection = new OleDbConnection(ConfigurationSettings.AppSettings["SQLConnectionString"]); if (strFocusArea == string.Empty || strFocusArea == txtFocusAreaWaterMark.WatermarkText) { lblError.Text = "Focus area is not entered"; } else { string insertQuery = "INSERT INTO LK_CODECAT_FOCUS_AREA(FOCUS_AREA_NAME,FK_ADDED_BY,ADDED_ON) "+ " VALUES('" + strFocusArea + "', "+Session["UserID"] +", GETDATE())"; try { myConnection.Open(); OleDbCommand myCommandToInsert = new OleDbCommand(insertQuery, myConnection); myCommandToInsert.ExecuteNonQuery(); } catch(Exception exc) { ExceptionLogger.LogException(exc); } finally { if (myConnection != null) { myConnection.Close(); } } PopulateFocusArea(); } txtFocusArea.Text = txtFocusAreaWaterMark.WatermarkText; } private void PopulateFocusArea() { OleDbConnection myConnection = new OleDbConnection(ConfigurationSettings.AppSettings["SQLConnectionString"]); string selectQuery = "SELECT PK_ID, FOCUS_AREA_NAME, IS_CURRENT_FOCUS FROM LK_CODECAT_FOCUS_AREA LKCFA ORDER BY FOCUS_AREA_NAME"; if (Session["RoleID"].ToString() == "1" || ((Session["WorkID"].ToString() != "9") || (Session["WorkID2"].ToString() != "9") || (Session["WorkID3"].ToString() != "9"))) { try { myConnection.Open(); OleDbCommand myCommandFocusArea = new OleDbCommand(selectQuery, myConnection); OleDbDataAdapter myAdapter = new OleDbDataAdapter(myCommandFocusArea); DataSet ds = new DataSet(); myAdapter.Fill(ds); dgFocusAreaDetails.DataSource = ds; dgFocusAreaDetails.ShowHeader = true; dgFocusAreaDetails.DataBind(); } catch (Exception exc) { ExceptionLogger.LogException(exc); } finally { if (myConnection != null) { myConnection.Close(); } } } } protected void dgFocusAreaDetails_SelectedIndexChanged(object sender, EventArgs e) { string selectedCategory = dgFocusAreaDetails.SelectedRow.Cells[1].Text; int index = dgFocusAreaDetails.SelectedIndex; lblError.Text = dgFocusAreaDetails.DataKeys[index].Value.ToString(); } public void OnCheckChangedEvent(object sender, EventArgs e) { CheckBox chk = (CheckBox)sender; string chkfocusarea = ((Control)chk).ID; //string focusAreaDetails = dgFocusAreaDetails.SelectedRow.Cells[0].Text; int index =Convert.ToInt32(dgFocusAreaDetails.SelectedIndex); if (chk.Checked) { string updateQuery = "UPDATE [LK_CODECAT_FOCUS_AREA] SET [IS_CURRENT_FOCUS] = 1 WHERE PK_ID = " +Convert.ToInt32( dgFocusAreaDetails.DataKeys[index].Value)+" "; } else { lblError.Text = "unchecked"; } } i want to know how i find the datakeyvalue on checked event.

    Read the article

  • Display weekday in textbox or label using date from textbox

    - by Niels Schultz
    I have a textbox with calendar extender and a label <label for="<%= tbxFrom.ClientID %>"> From</label> <asp:Label ID="lblWeekDayFrom" runat="server"></asp:Label> <asp:TextBox ID="tbxFrom" runat="server" CssClass="Calendar"></asp:TextBox> <cc1:CalendarExtender ID="extTbxFrom" runat="server" TargetControlID="tbxStartTag"> </cc1:CalendarExtender> and now I would like to show the weekday of the currently selected date, either using a formatting inside the textbox like Th 05/20/2010 or showing the weekday as string using the label on the left side of the texbox (lblWeekDayFrom). There is a calendarExtender to select the date, but I would also like to be able to have the users enter the date manually. I tried to use JQuery to capture changes, but the label is not showing anything, and it triggers the RequiredFieldValidator on every initial page load. $(document).ready(function() { $('#<%= tbxFrom.ClientID %>').change(updateDate($('#<%= tbxFrom.ClientID %>').val())) } ); function updateDate(date) { $('#<%= lblWeekDayFrom.ClientID %>').val(date); }

    Read the article

  • Conditional required field validation in an ASP.net ListView

    - by Jim Dagg
    I'm having a heck of a time trying to figure out how to implement validation in a ListView. The goal is to require the user to enter text in the comments TextBox, but only if the CheckBox is checked. Downside is that these controls are in the EditTemplate of a ListView. Below is a snippet of the relevant code portion of the EditTemplate: <tr style="background-color: #00CCCC; color: #000000"> <td> Assume Risk? <asp:CheckBox ID="chkWaive" runat="server" Checked='<%# Bind("Waive") %>' /> </td> <td colspan="5"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Comments required" ControlToValidate="txtComments" /> <asp:TextBox Width="95%" ID="txtComments" runat="server" Text='<%# Eval("Comment") %>'></asp:TextBox> </td> <td> <asp:Button ID="btnSave" runat="server" Text="Save" CommandName="Update" Width="100px" /> </td> </tr> Is there a way to do conditional validation using this method? If not, is there a way I could validate manually in the ItemUpdating event of the Listview, or somewhere else, and on a failure, alert the user of the error via a label or popup alert?

    Read the article

  • Custom CheckBoxList in ASP.NET

    - by Rick
    Since ASP.NET's CheckBoxList control does not allow itself to be validated with one of the standard validation controls (i.e., RequiredFieldValidator), I would like to create a UserControl that I can use in my project whenever I need a checkbox list that requires one or more boxes to be checked. The standard CheckBoxList can be dragged onto a page, and then you can manually add <asp:ListItem> controls if you want. Is there any way I can create a UserControl that lets me manually (in the markup, not programmatically) insert ListItems from my page in a similar manner? In other words, can I insert a UserControl onto a page, and then from the Designer view of the Page (i.e., not the designer view of the UserControl), can I manually add my ListItems like so: <uc1:RequiredCheckBoxList> <asp:ListItem Text="A" value="B"></asp:ListItem> <asp:ListItem Text="X" value="Y"></asp:ListItem> </uc1:RequiredCheckBoxList> If a UserControl is not the appropriate choice for the end result I'm looking for, I'm open to other suggestions. Please note that I am aware of the CustomValidator control (which is how I plan to validate within my UserControl). It's just a pain to write the same basic code each time I need one of these required checkbox lists, which is why I want to create a re-usable control.

    Read the article

  • ASP.NET: aggregating validators in a user control

    - by orsogufo
    I am developing a web application where I would like to perform a set of validations on a certain field (an account name in the specific case). I need to check that the value is not empty, matches a certain pattern and is not already used. I tried to create a UserControl that aggregates a RequiredFieldValidator, a RegexValidator and a CustomValidator, then I created a ControlToValidate property like this: public partial class AccountNameValidator : System.Web.UI.UserControl { public string ControlToValidate { get { return ViewState["ControlToValidate"] as string; } set { ViewState["ControlToValidate"] = value; AccountNameRequiredFieldValidator.ControlToValidate = value; AccountNameRegexValidator.ControlToValidate = value; AccountNameUniqueValidator.ControlToValidate = value; } } } However, if I insert the control on a page and set ControlToValidate to some control ID, when the page loads I get an error that says Unable to find control id 'AccountName' referenced by the 'ControlToValidate' property of 'AccountNameRequiredFieldValidator', which makes me think that the controls inside my UserControl cannot resolve correctly the controls in the parent page. So, I have two questions: 1) Is it possible to have validator controls inside a UserControl validate a control in the parent page? 2) Is it correct and good practice to "aggregate" multiple validator controls in a UserControl? If not, what is the standard way to proceed?

    Read the article

< Previous Page | 1 2 3 4  | Next Page >