简体   繁体   English

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

[英]handling multiple ajaxtoolkit rating control BehaviorID's on a single page

I have a webform which dynamically loads a web user control in it. 我有一个Webform,可以在其中动态加载Web用户控件。 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. Web用户控件中有一个转发器控件,而在转发器控件中,我有一个针对每个重复项的ajaxtoolkit评分控件,并且Web用户控件可以根据需要在自身内部动态创建多次。 To handle the selected rating I have to use BehaviorID along with the following code: 要处理选定的评分,我必须将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>

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. 如果我取出BehaviorID,则一切正常。

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? 我的问题是,由于每个评分控件都需要这些项目,我该如何为多个BehaviorID和每个脚本编写代码?

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 并在repeating_ItemDataBound中

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM