呼吁&QUOT jQuery函数; onSelectedIndexChanged" [英] Call jquery function on "onSelectedIndexChanged"

查看:62
本文介绍了呼吁&QUOT jQuery函数; onSelectedIndexChanged"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个下拉列表和一个文本框。
我想从两个下拉列表显示所选值的乘积。

I have two drop-downs and one text box. I want to display multiplication of selected values from both the drop-downs.

所以,我试图调用一个jQuery函数OnSelectedIndexChanged甚至下拉菜单。 Hoever我构建在Visual Studio中收到错误。

So i am trying to call a jquery function on "OnSelectedIndexChanged" even of dropdowns. Hoever I am getting error during build in Visual studio.

我的code是:

<asp:DropDownList ID="ddlProbability" runat="server" Width="125px" OnSelectedIndexChanged="javascript:calculateRiskFactor();">

错误是:无效前pression术语:和
无效前pression术语')和一些

什么不对语法,或者这是错误的方式来调用一个函数?

Is anything wrong with syntax or this is wrong way to call a function?

整个页面code是这样的:

The whole page code is something like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Submit_Risks.aspx.cs" Inherits="Risks_Submit_Risks" MasterPageFile="~/MasterPages/SAPMaster.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">    
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/Validation.js"> </script>
<div class="container">
    <div class="contain">
        <div class="title">
            Risks</div>
        <div class="data">
            <asp:Label runat="server" ID="lblMsg"></asp:Label>
            <table class="style1" align="center">

                <tr>
                    <td class="style2">
                        Probability (P)
                    </td>
                    <td class="style3">
                        <asp:DropDownList ID="ddlProbability" runat="server" Width="125px">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="rfvProbability" runat="server" ControlToValidate="ddlProbability"
                            InitialValue="0" ValidationGroup="vgSubmit" ErrorMessage="Probability" ForeColor="Red"
                            Text="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td class="style2">
                        Impact (S)
                    </td>
                    <td class="style3">
                        <asp:DropDownList ID="ddlImpact" runat="server" Width="125px">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="rfvImpact" runat="server" ControlToValidate="ddlImpact"
                            InitialValue="0" ValidationGroup="vgSubmit" ErrorMessage="Impact" ForeColor="Red"
                            Text="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
                    </td>
                </tr>
    </div>
    </div>
</div>

推荐答案

据我可以从ASP.NET的WebForms记住, OnSelectedIndexChanged 只点背以.NET服务器端函数,它与ASP.NET回发(纠正我,如果我错了)。

As far as I can remember from ASP.NET WebForms, OnSelectedIndexChanged only points back to a .NET server-side function, which ASP.NET calls with a postback (correct me if I'm wrong).

要客户端code绑定到控件(如使用jQuery),为什么不使用jQuery来为你做它?

To bind client-side code to the control (like with jQuery), why not use jQuery to do it for you?

$('select[id$="ddlProbability"]').change(calculateRiskFactor);

这篇关于呼吁&QUOT jQuery函数; onSelectedIndexChanged&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆