添加到MasterPage时,下拉列表不会更新。 [英] Dropdown List is not updating when added to MasterPage.

查看:66
本文介绍了添加到MasterPage时,下拉列表不会更新。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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}

>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>>>>>> ;>>>>>>>>>>>>>>>>>>>>



我在updatepanel中有网格。当我选择弹出面板显示的行时,文本中有正确的下拉选择。我在Watch窗口中看不到正确的值。 DropDownList显示SelectedVal中的None和SelectedItem中的{Select Day}的值.SelectedValue的实际值应为1,SelectedItem应为{Monday}。我可以选择列表中的任何项目, SelectValue中的None和SelectedItem中的{Select Day}得到相同的东西。None和{Select Day}或列表中的第一项。我试图使用findcontrol并看到同样的问题无和{选择日}。下拉列表加载源文件。



更多详情下面:

下拉列表是添加到MasterPage时不会更新。我的下拉列表位于Updatepanel面板中。我在更新面板中有一个网格。网格有编辑链接,启动一个带有下拉列表的面板。我的代码基于以下示例:



使用GridView弹出编辑/添加/删除记录 [ ^ ]



在将代码添加到母版页之前,一切正常。 scriptmanager已添加到母版页。我尝试了下面的解决方案,但仍然无法获得列表中的实际值。在做手表时,我看到索引0的默认值而不是显示的实际值。我可以选择列表中的任何项目,但不会在手表中显示。



建议不起作用:

如果您的下拉列表是在更新面板中,在您使用更新面板触发器之前,下拉列表selectedIndex将不会触发。



< triggers>

< asp:asyncpostbacktrigger controlid =DropDownList1eventname =SelectedIndexChangedxmlns:asp =#unknown/>


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}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

I have the grid in the updatepanel. When I select the row the popup panel show with the correct dropdown selection in the text. I do not see the correct value in the Watch window. The DropDownList show me the value of "None in the SelectedValue and {Select Day}in the SelectedItem. The actual Value of the SelectedValue should be "1" and the SelectedItem should be {Monday}. I can select any item in the list and I get the same thing of "None" in the SelectValue and {Select Day} in the SelectedItem. The "None" and {Select Day} or the first items in the list. I attempted to use the findcontrol and see the same problem of "None" and {Select Day}. The Dropdown list is load with a source file.

More Details Below:
Dropdown List is not update when added to MasterPage. My Dropdown list is with in a panel of Updatepanel. I have a grid within a updatepanel. The grid has edit link that launches a panel that has a dropdown list. I base my code on this example below:

Popup Editing/Adding/Deleting Records with GridView[^]

Everything was working properly until the code was added to the masterpage. The scriptmanager was added to the masterpage. I attempted the solution below but still not able get the actual value on the list. When doing a watch, I see the default of index 0 and not the actual value that is showing. I can select any items in the list and it does not show in the watch.

Suggestion did not work:
If your dropdown is in the update panel then the dropdown selectedIndex will not fire until you used Update panel trigger.

<triggers>
<asp:asyncpostbacktrigger controlid="DropDownList1" eventname="SelectedIndexChanged" xmlns:asp="#unknown" />

推荐答案

您是否尝试从内容页面的上下文或母版页的上下文角度查看值?



如果代码和控件驻留在母版页上,并且您想从内容页面访问它们,则需要首先获取对控件的引用来访问它们第一个。



Are you trying to view the values from the perspective of the content page's context or master page's context?

If the code and controls reside on the master page and you want to access them from the content page, you will need to access them by first getting a reference to the controls first.

DropDownList masterDropDownList = this.Master.FindControl("DropDownList1") as DropDownList;





希望这会有所帮助。



Hope this helps.


这篇关于添加到MasterPage时,下拉列表不会更新。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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