Home > AJAX, ASP.Net > Validating AJAX Rating Control

Validating AJAX Rating Control


Hi

try this Example:-

<ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
                <ajaxToolkit:Rating ID="ThaiRating" runat="server" BehaviorID="RatingBehavior1"
                    CurrentRating="0"
                    MaxRating="5"
                    StarCssClass="ratingStar"
                    WaitingStarCssClass="savedRatingStar"
                    FilledStarCssClass="filledRatingStar"
                    EmptyStarCssClass="emptyRatingStar"
                    OnChanged="ThaiRating_Changed"
                    style="float: left;" />
                   
        <asp:Button ID="Button1" runat="server" Text="Button"  />
        <asp:CustomValidator id="CustomValidator1" runat="server" Display="Dynamic" ErrorMessage="Please slect rating" ClientValidationFunction="CustomValidator1_ClientValidate" ></asp:CustomValidator>

    </div>
    </form>
    <script type="text/javascript">

function CustomValidator1_ClientValidate(source,args)
{  

    if($find('RatingBehavior1').get_Rating() != 0) // rating is not zero
    {
        args.IsValid = true;
    }
    else
    {
        args.IsValid = false;
    }
}

</script>

Hope this helps

Good Luck

Advertisements
Categories: AJAX, ASP.Net
  1. guna
    November 22, 2012 at 1:34 pm

    how to get and set ajax rating control value in jquery.. and assign rating value 0

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: