Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're not validating the dropdown list are you? You're validating the value a user selected. It's pretty much the same advice as the other post, since javascript or other tools can alter the html or create their own POST's, you <em>must always</em> validate on the server side. Assume all client requests can be tampered with, and assume that no client-side validation has occurred.</p> <hr> <p>If you're using the web forms model ....</p> <p>If you just want to check a value was selected in the dropdown <code>myAjaxDropDown</code>, use the </p> <pre><code>&lt;asp:RequiredFieldValidator id="dropdownRequiredFieldValidator" ControlToValidate="myAjaxDropDown" Display="Static" InitialValue="" runat=server&gt; * &lt;/asp:RequiredFieldValidator&gt; </code></pre> <p>You could also want to look at the asp:CustomValidator - for server side validation:</p> <pre><code>&lt;asp:CustomValidator ID="myCustomValidator" runat="server" onservervalidate="myCustomValidator_ServerValidate" ErrorMessage="Bad Value" /&gt; </code></pre> <p>Both plug into the validation framework of asp.net. e.g. when you click a button called <code>SumbitButton</code></p> <pre><code>protected void myCustomValidator_ServerValidate(object source, ServerValidateEventArgs e) { // determine validity for this custom validator e.IsValid = DropdownValueInRange(myAjaxDropDown.SelectedItem.Value); } protected void SubmitButton_Click( object source, EventArgs e ) { Validate(); if( !IsValid ) return; // validators pass. Continue processing. } </code></pre> <p>Some links for further reading:</p> <ul> <li><a href="http://quickstart.developerfusion.co.uk/QuickStart/aspnet/doc/validation/default.aspx" rel="nofollow noreferrer">ASP.Net 2.0 Quickstart - Validating Form Input Controls</a></li> <li><a href="http://www.dotnetcurry.com/ShowArticle.aspx?ID=121&amp;AspxAutoDetectCookieSupport=1" rel="nofollow noreferrer">ASP.NET Validation Controls – Important Points, Tips and Tricks</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload