Ajax更新面板无法正常工作 [英] Ajax update panel not working

查看:80
本文介绍了Ajax更新面板无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题的历史

使用Visual Studio 2010在分离的项目中创建正在运行的代码.Ajax dll是AJAX Control Toolkit - 2013年12月发行版。该文件是从 http://www.asp.net/ajaxlibrary/act.ashx [ ^ ]。此文件中提供的scriptmanager是ToolkitScriptManager。此代码被复制到现有项目中。



现有问题项目的历史:



此项目已从Visual Studio 2008更新到Visual Studio 2010.该项目有两个AJAX文件夹,或标记Ajax Ver 3.5和AJAX ver 4.0。此外,该项目使用ScriptManager而不是ToolkitScriptManager。 ScriptManager将添加到MasterPage。当我将工作项目中的代码复制到项目中时,我删除了我在项目中使用的ToolkitScriptManager,并使用了旧应用程序中的现有项目ScriptManager。在尝试从下拉列表中获取值之前,一切似乎都在起作用。返回的值是默认值,而不是从列表中选择的值。我不确定从Visual Studio 2008和Visual Studio 2010升级应用程序是否是问题。我不确定Ajax文件夹(3.5和4.0)或正在使用。



我在工作的aspx页面中将MasterPage设置为母版页中的相同代码代码正常工作。



>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>

任何人都可以告诉我为什么在程序中它给我一个问题已经文件asp.designer.aspx。一些解决方案提到了关于* .aspx.designer.aspx文件中控件缺少AjaxControlToolKit的事情。你能否详细介绍* .aspx.designer.aspx中可能需要的内容。这些只是简单的aspx下拉控件。



>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>

我有尝试几件事,下拉列表不能正常工作。我创建了两个版本的项目。用于测试代码的示例项目正在运行。但是,当我将代码移动到现有项目时,问题就开始了。设计师代码中是否需要一些东西。



给出错误的下拉列表我可以在代码的Designer中看到它们。我再次认为错误来自下拉列表。在设计器代码中,我看到protected global :: System.Web.UI.WebControls.DropDownList ddlList;应该是不同的东西,因为它在更新和面板控制范围内。



旧的附加信息

>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>

我在aspx页面的更新面板中有三个下拉列表。但是直到它给回发。请帮我解决问题。



工作时的状态:

它使用下面的具有下拉列表的ASP.NET表单中的ToolkitScriptManager。此外,当您将ToolkitScriptManager添加到与表单关联的MasterPage时,下拉工作正常工作



< asp:ToolkitScriptManager ID =tsmrunat =服务器>





问题开始时的状态。

当我添加以下内容时问题开始Scriptmanager in form或MasterPage



< asp:ScriptManager ID =smrunat =serverScriptMode =Release>





行:524

错误:无法获取属性UI的值:object为null或undefined。当我没有收到该错误时,我可以看到所选的项目,但无法在手表中看到它。它显示的默认值是SelectValue为0和SelectItem.Text {Select Item}



如果有人能提出解决方案,请提前感谢问题。我尝试了几件事。

解决方案

Quote:

1。首先,您必须在项目引用中添加AjaxControlToolkit.dll。

2.添加



<%@ Register Assembly =AjaxControlToolkit命名空间=AjaxControlToolkitTagPrefix =asp%>


页面目录中的




3.将脚本管理器添加到您的aspx页面



 <  < span class =code-leadattribute> asp:ScriptManager     ID   =  ScriptManager1    runat   =  server >  
< / asp:ScriptManager >







4.最后在更新面板中添加以下代码。





 <   asp:UpdatePanel     ID   =  pnlupdate    runat   = 服务器 >  
< ContentTemplate >
< asp:DropDownList ID = ddlList runat = server < span class =code-attribute> AutoPostBack = true >
< asp:ListItem 文本 = - 选择 - = - 选择 - > < / asp:ListItem >
< asp:ListItem 文本 = laptop = 笔记本电脑 > < / asp: ListItem >
< asp:ListItem 文本 = 移动 = 移动 > < / asp:ListItem >
< / asp:DropDownList >
< / ContentTemplate >
< / asp:UpdatePanel >


问候:



我想出了一个解决方案。我只是从主页的容器中的代码周围删除了UpdatePanel。我要感谢所有回答我问题的人。



如下所示:答案:



http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+the+application [< a href =http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+the+applicationtarget = _blanktitle =新窗口> ^ ]







 <   asp:UpdatePanel     ID   =  up    runat   =  server    UpdateMode   = 条件    BackColor   = #C0FFC0  

CssClass = 面板 >
< ContentTemplate >


问候语:

我想出了一个解决方案。我只是从主页的容器中的代码周围删除了UpdatePanel。我要感谢所有回答我问题的人。

如下所示:答案:

< a href = http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+ +应用程序 > http://forums.asp.net/t/1608556.aspx?Error+Two+components+with++相同+ id + can + t + be + added + to + the application < / a < span class =code-keyword>> [< a href = http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+the+application target = _ blank title = 新窗口 > ^ < / a > ]



< pre lang = xml > & lt; asp:UpdatePanel ID =& quot; up& quot; RUNAT =安培; QUOT;服务器&安培; QUOT;的UpdateMode =安培; QUOT;条件&安培; QUOT;背景色=安培; QUOT;#C0FFC0&安培; QUOT;
CssClass =& quot; panel& quot;& gt;
& lt; ContentTemplate& gt; < / pre >


History of problem
The code that is working was created in it on separated project with Visual Studio 2010. The Ajax dll was AJAX Control Toolkit — December 2013 Release. The file was downloaded from http://www.asp.net/ajaxlibrary/act.ashx[^]. The scriptmanager that was available from this file was ToolkitScriptManager. This code was copy over into a existing project.

History on existing problem project:

This project was updated from Visual Studio 2008 to Visual Studio 2010. The project has two AJAX Folders which or label Ajax Ver 3.5 and AJAX ver 4.0. Also, the project is using the ScriptManager and not ToolkitScriptManager. The ScriptManager is added to the MasterPage. When I copy the code from working project into the project I remove the ToolkitScriptManager which I was using in the project and used the existing project ScriptManager which is in the old application. Everything seem to be working until attempted to grab the value from the dropdownlist. The value being return were the default value and not the value being selected from the list. I am not sure if the upgrade of the application from Visual Studio 2008 and Visual Studio 2010 is the problem. I am not sure with of the Ajax folder (3.5 and 4.0) or being used.

I setup the MasterPage in the working aspx page to identical code in the master page inwhich the code is working.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Can anyone tell me why in the program that it is giving me a problem has the file asp.designer.aspx. Some of the solution have mention somethings about the AjaxControlToolKit is missing for the control within the *.aspx.designer.aspx file. Can you give me some detail on what may be needed in the *.aspx.designer.aspx. These are only simple aspx dropdown control.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I have attempt several things and the dropdown are not working properly. I created two version of the project. The sample project to test out the code is working. But, when I move the code over into a existing project the problem starts. Could there be somethings that is needed in the designer code.

The dropdown that are giving the error could I see them in the Designer of the code. Again, I think the error are coming from the dropdown. In the designer code I see protected global::System.Web.UI.WebControls.DropDownList ddlList; should it be something different because it is within the Update and Panel control.

Old additional information
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I have the three dropdownlist inside the update panel in my aspx page.But till it is giving the postbacks.Please help me in solving the issue.

State when working:
It work with the below ToolkitScriptManager in the ASP.NET Form that has the drop down. Also, the drop down work properly when you add the ToolkitScriptManager to the MasterPage which is associated with the form

<asp:ToolkitScriptManager ID="tsm" runat="server">


State when the problem start.
The problem start when I add the following Scriptmanager in form or MasterPage

<asp:ScriptManager ID="sm" runat="server" ScriptMode="Release" >


Line: 524
Error: Unable to get value of the property 'UI': object is null or undefined. When I am not getting that error, I can see the item that is select but can not see it in the watch. It is showing the default value which is the SelectValue of 0 and SelectItem.Text of {Select Item}

Thank in advance if anyone can come up with the solution to this problem. I have attempted several things.

解决方案

Quote:

1. First you have to add AjaxControlToolkit.dll in your project references.
2. Add

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

in your page directory.

3. add script manager to your aspx page

<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>




4. In Last add below code in update panel.



<asp:UpdatePanel ID="pnlupdate" runat="server">
            <ContentTemplate>
            <asp:DropDownList ID="ddlList" runat="server" AutoPostBack="true">
            <asp:ListItem Text = "--Select--" Value="--Select--"></asp:ListItem>
            <asp:ListItem Text = "laptop" Value="laptop"></asp:ListItem>
            <asp:ListItem Text = "Mobile" Value="Mobile"></asp:ListItem>
            </asp:DropDownList>
            </ContentTemplate>
</asp:UpdatePanel>


Greetings:

I have come up with a solution. I simply removed the UpdatePanel from the from around the code that is in container of the masterpage. I wish to thank everyone who replied to my problem.

Referred to the below for the answer:

http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+the+application[^]



<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional" BackColor="#C0FFC0"

           CssClass="panel">
               <ContentTemplate>


Greetings:

I have come up with a solution. I simply removed the UpdatePanel from the from around the code that is in container of the masterpage. I wish to thank everyone who replied to my problem.

Referred to the below for the answer:

<a href="http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+the+application">http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+the+application</a>[<a href="http://forums.asp.net/t/1608556.aspx?Error+Two+components+with+the+same+id+can+t+be+added+to+the+application" target="_blank" title="New Window">^</a>]



<pre lang="xml">&lt;asp:UpdatePanel ID=&quot;up&quot; runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot; BackColor=&quot;#C0FFC0&quot;
           CssClass=&quot;panel&quot;&gt;
               &lt;ContentTemplate&gt;</pre>


这篇关于Ajax更新面板无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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