我有一个应用程序,其中javascript读取设备的GPS位置并将其发送到服务器端脚本,如下所示:
f()
{
var initialLocation= Someshit();
document.getElementById('<% = text.ClientID %>').value=initialLocation;
var button = document.getElementById('<% = Button4.ClientID %>');
button.click();
}我有一些AJAX.NET代码:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button4" runat="server" Text="PlaceHolder" onclick="Button4_Click"/>
<asp:TextBox ID="text" runat="server"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>再往下一点
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div>
<some divs and asp:gridviews and god knows what >
</div>
<ContentTemplate>
</asp:UpdatePanel>问题是,当UpdatePanel1事件结束时,最后一个div内部内容会发生变化。为什么会这样呢?我不希望UpdatePanel1之外的内容在UpdatePanel1做它的事情时被更改。请帮帮忙。
发布于 2010-05-26 14:59:02
默认的UpdateMode是Always,在本例中您需要Conditional,如下所示:
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
Yadda yadda
</div>
<ContentTemplate>
</asp:UpdatePanel>来自MSDN,这里的区别是:
- If the [`Update`](http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.update.aspx) method of the UpdatePanel control is called explicitly.
- If a control is defined as a trigger by using the Triggers property of the UpdatePanel control and causes a postback. In this scenario, the control is an explicit trigger for updating the panel content. The trigger control can be either inside or outside the UpdatePanel control that defines the trigger.
- If the [`ChildrenAsTriggers` property](http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.childrenastriggers.aspx) is set to true and a child control of the UpdatePanel control causes a postback. In this scenario, child controls of the UpdatePanel control are implicit triggers for updating the panel. Child controls of nested UpdatePanel controls do not cause the outer UpdatePanel control to be updated unless they are explicitly defined as triggers.
https://stackoverflow.com/questions/2914080
复制相似问题