CustomValidator Control

Discussion in 'ASP .Net' started by Jim Heavey, Dec 2, 2003.

  1. Jim Heavey

    Jim Heavey Guest

    Hello, I was am wanting to validate that a user has made a selection from a
    dropdownlist control in a datagrid. Is my only option to use a
    "CustomValidator Control"? I am not quite sure how to write and attach
    JavaScript to the control to ensure the SelectedIndex > -1. Is there a way
    to do this in JavaScript (can you provide an example?) or should I just
    write Server side validation?

    Example:


    <asp:DropDownList ID="ddlRating" Runat="server" DataSource="<%#
    dtRating %>" DataTextField="Description" DataValueField="Rating" Font-
    Size="8"></asp:DropDownList>

    <asp:CustomValidator ID="cvlRating" ControlToValidate="ddlrating"
    Display="Dynamic" ErrorMessage="Must make a selection">
    </asp:CustomValidator>
     
    Jim Heavey, Dec 2, 2003
    #1
    1. Advertising

  2. Jim Heavey

    AW Guest

    Hi,

    You should not write any javascript that interferes with a WebControl. This
    is because you have NO guarantee on the tags/HTML that will be generated by
    the WebControl on a different browser or a different version of ASP.Net.

    Consider writing just the server-side validation or using an HtmlControl
    (<SELECT runat="server">).
    --
    To reply, remove a "l" before the @ sign.

    Arnaud Weil - MCT, MCSD.Net, MCAD.Net
     
    AW, Dec 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Vmk=?=

    CustomValidator Control

    =?Utf-8?B?Vmk=?=, Oct 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    362
    Scott Allen
    Oct 21, 2004
  2. Dan Sikorsky
    Replies:
    1
    Views:
    5,861
    Dan Sikorsky
    Feb 17, 2005
  3. avp
    Replies:
    1
    Views:
    21,679
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Dec 16, 2005
  4. Replies:
    1
    Views:
    389
    Brennan Stehling
    Oct 26, 2006
  5. Arti
    Replies:
    0
    Views:
    327
Loading...

Share This Page