在单个页面上处理多个ajaxtoolkit评级控制BehaviorID

发布于 2024-12-01 22:13:33 字数 827 浏览 2 评论 0原文

我有一个网络表单,可以在其中动态加载网络用户控件。 Web 用户控件内有一个转发器控件,在转发器控件内,我为每个重复项目提供了一个 ajaxtoolkit 评级控件,并且 Web 用户控件可以根据需要在其内部动态创建任意多次。要处理选定的评级,我必须使用 BehaviorID 以及以下代码:

<script type="text/javascript">
    function pageLoad() { $find("ratingControlBehavior").add_EndClientCallback(onClientCallBack); }
    function onClientCallBack(sender, eventArgs) {
        var htmlname = sender._callbackID.substring(0, sender._callbackID.lastIndexOf('$')) + '_hdrating';
        htmlname = htmlname.replace(/\$/g, '_')
        var hdctl = document.getElementById(htmlname);
        hdctl.value = eventArgs.get_CallbackResult(); 
    }
</script>

问题是,当表单上同时出现多个评级控件时,只有第一个评级控制起作用,其他评级被禁用。如果我取出BehaviorID,那么一切都会正常。

我的问题是,由于每个评级控件都需要这些项目,因此我将如何为多个BehaviorID 以及每个BehaviorID 编写脚本?

I have a webform which dynamically loads a web user control in it. Within the web user control is a repeater control and within the repeater control I have an ajaxtoolkit rating control for each repeating item, and the web user control can be dynamically created within it self as many times as needed. To handle the selected rating I have to use BehaviorID along with the following code:

<script type="text/javascript">
    function pageLoad() { $find("ratingControlBehavior").add_EndClientCallback(onClientCallBack); }
    function onClientCallBack(sender, eventArgs) {
        var htmlname = sender._callbackID.substring(0, sender._callbackID.lastIndexOf('

the issue is, when more than one rating control is on the form at once, only the first rating control works, the other ratings are disabled. If I take out the BehaviorID then all works fine.

My question is, how would I code for multiple BehaviorID's as well as the script for each, since I need these items for each rating control?

)) + '_hdrating'; htmlname = htmlname.replace(/\$/g, '_') var hdctl = document.getElementById(htmlname); hdctl.value = eventArgs.get_CallbackResult(); } </script>

the issue is, when more than one rating control is on the form at once, only the first rating control works, the other ratings are disabled. If I take out the BehaviorID then all works fine.

My question is, how would I code for multiple BehaviorID's as well as the script for each, since I need these items for each rating control?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扛刀软妹 2024-12-08 22:13:33

这是通过执行以下操作来完成的:

    String scriptText = "";
    scriptText += "function pageLoad(){";
    foreach ( group.category.point item in tpnts )
    { scriptText += "     $find('ratingControlBehavior" + item.eval_id + "').add_EndClientCallback(onClientCallBack);"; }
    scriptText += "}";
    ClientScriptManager csm = ClientScript;
    csm.RegisterStartupScript(this.GetType(), "scriptonload", scriptText, true);

并且在repeating_ItemDataBound内

        rating.BehaviorID = "ratingControlBehavior" + pnt.eval_id.ToString();

This was accomplished by doing the following:

    String scriptText = "";
    scriptText += "function pageLoad(){";
    foreach ( group.category.point item in tpnts )
    { scriptText += "     $find('ratingControlBehavior" + item.eval_id + "').add_EndClientCallback(onClientCallBack);"; }
    scriptText += "}";
    ClientScriptManager csm = ClientScript;
    csm.RegisterStartupScript(this.GetType(), "scriptonload", scriptText, true);

and within the repeating_ItemDataBound

        rating.BehaviorID = "ratingControlBehavior" + pnt.eval_id.ToString();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文