【问题标题】:what is the correct configuration of RadAjaxManager - this issue is in ralationship with UpdatePanel !RadAjaxManager 的正确配置是什么 - 这个问题与 UpdatePanel 有关系!
【发布时间】:2010-04-27 16:33:45
【问题描述】:

首先看下面的aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="Amlak.WebForm4" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="CheckBox1" UpdatePanelRenderMode="Inline" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" AppendDataBoundItems="True"
            OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
            <Items>
                <telerik:RadComboBoxItem runat="server" Text="1" Value="1" />
                <telerik:RadComboBoxItem runat="server" Text="2" Value="2" />
                <telerik:RadComboBoxItem runat="server" Text="3" Value="3" />
                <telerik:RadComboBoxItem runat="server" Text="4" Value="4" />
            </Items>
        </telerik:RadComboBox>
        <br />
        <br />
        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged"
            Text="Check Me" TextAlign="Left" />
        <br />
        <br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

我后面的代码是这样的:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Amlak
{
    public partial class WebForm4 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (RadComboBox1.SelectedItem.Value == "2")
            {
                CheckBox1.Checked = true;
            }
            else
            {
                CheckBox1.Checked = false;
            }

        }

        protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (CheckBox1.Checked)
            {
                TextBox1.Text = "text";
            }
            else
            {
                TextBox1.Text = "";
            }
        }
    }
}

我的目标:

  1. 我想强制RadComboBox1 在 AJAX 模式下工作,并通过后面代码中定义的条件更改 CheckBox1.Checked。 -> 不希望为此回发。

  2. 我想强制 CheckBox1 在 PostBack 模式下工作,并通过后面代码中定义的条件更改 TextBox1.text。 -> 我想要回发这个。

在这种情况下 -> RadComboBox1 工作正常
但我不知道为什么当我们更改CheckBox1 的检查时OnCheckedChanged="CheckBox1_CheckedChanged" 不会触发! (因为我们将它作为RadComboBox1 的更新添加到RadAjaxManager1 中)。


我的问题:

我是否应该添加RadComboBox1 作为RadComboBox1 的更新?但是,如果不添加它,它可以正常工作。

如果我们将ChechBox1 添加到RadAjaxManager1,如下所示:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="Amlak.WebForm4" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="CheckBox1" UpdatePanelRenderMode="Inline" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="CheckBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="TextBox1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" AppendDataBoundItems="True"
            OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
            <Items>
                <telerik:RadComboBoxItem runat="server" Text="1" Value="1" />
                <telerik:RadComboBoxItem runat="server" Text="2" Value="2" />
                <telerik:RadComboBoxItem runat="server" Text="3" Value="3" />
                <telerik:RadComboBoxItem runat="server" Text="4" Value="4" />
            </Items>
        </telerik:RadComboBox>
        <br />
        <br />
        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged"
            Text="Check Me" TextAlign="Left" />
        <br />
        <br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>

所以它在 AJAX 模式下工作正常,但我想强制 CheckBox1 在 PostBack 中工作!
我该如何解决这个问题?

我是否应该在RadAjaxManager 中添加TextBox1 作为RadComboBox1 的更新?

感谢您关注我的问题。 最好的问候

【问题讨论】:

  • 我有 2 个来自该社区经理的问题:1-这里有任何人 / 2-为什么通知电子邮件对我不起作用(我检查了通知复选框)? (我在这个社区哪里可以问这样的问题?)

标签: asp.net ajax visual-studio-2010 updatepanel radajaxmanager


【解决方案1】:

Current RadAjax Limitations 说,

RadAjaxManager 设置不会 ajaxify 按钮... ...当没有更新的控件时

因此,您可能必须执行以下操作:

<UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="ChechBox1" />
</UpdatedControls>

【讨论】:

    【解决方案2】:

    您甚至可以利用 RadAjaxManager 的 OnRequestStart 来禁用特定请求的 Ajax 功能。这是您的代码的更新版本,可按您的要求工作:

    <div>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl
                            ControlID="CheckBox1"
                            UpdatePanelRenderMode="Inline" />
                        <telerik:AjaxUpdatedControl
                            ControlID="TextBox1"
                            UpdatePanelRenderMode="Inline" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="CheckBox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl
                            ControlID="TextBox1"
                            UpdatePanelRenderMode="Inline" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
            <ClientEvents OnRequestStart="onAjaxRequestStart" />
        </telerik:RadAjaxManager>
    
        <telerik:RadComboBox ID="RadComboBox1" runat="server"
            AutoPostBack="True"
            AppendDataBoundItems="True"
            OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
            <Items>
                <telerik:RadComboBoxItem runat="server" Text="1" Value="1" />
                <telerik:RadComboBoxItem runat="server" Text="2" Value="2" />
                <telerik:RadComboBoxItem runat="server" Text="3" Value="3" />
                <telerik:RadComboBoxItem runat="server" Text="4" Value="4" />
            </Items>
        </telerik:RadComboBox>
    
        <br />
        <br />
    
        <asp:CheckBox ID="CheckBox1" runat="server"
            AutoPostBack="True"
            OnCheckedChanged="CheckBox1_CheckedChanged"
            Text="Check Me"
            TextAlign="Left" />
    
        <br />
        <br />
    
        <asp:TextBox ID="TextBox1" runat="server" />
    
        <telerik:RadCodeBlock runat="server">
            <script type="text/javascript">
                function onAjaxRequestStart(s, e) {
                    var target = e.get_eventTarget(),
                        checkBoxId = '<%= CheckBox1.ClientID %>';
                    if (target === checkBoxId) {
                        e.set_enableAjax(false);
                    }
                }
            </script>
        </telerik:RadCodeBlock>
    </div>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-18
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      相关资源
      最近更新 更多