Javascript ASP.NET UpdatePanel和按钮未执行完全和/或部分回发
我知道这是一个常见的问题,但我确信我的代码是足够正确的,它不适合我。我有一个模态窗口,当它打开时,会显示一个UpdatePanel,其中有几个面板,其中一个面板上有一个普通按钮。单击按钮不会提供任何回发(部分或全部)。理想情况下,我只想做部分回发,但我现在无法获得任何类型的回发。以下是我的一些代码: 对于ScriptManager:Javascript ASP.NET UpdatePanel和按钮未执行完全和/或部分回发,javascript,asp.net,modal-dialog,updatepanel,partial-postback,Javascript,Asp.net,Modal Dialog,Updatepanel,Partial Postback,我知道这是一个常见的问题,但我确信我的代码是足够正确的,它不适合我。我有一个模态窗口,当它打开时,会显示一个UpdatePanel,其中有几个面板,其中一个面板上有一个普通按钮。单击按钮不会提供任何回发(部分或全部)。理想情况下,我只想做部分回发,但我现在无法获得任何类型的回发。以下是我的一些代码: 对于ScriptManager: myScriptManager.ID = "ScriptManager1" myScriptManager.EnablePageMethods = True
myScriptManager.ID = "ScriptManager1"
myScriptManager.EnablePageMethods = True
myScriptManager.EnablePartialRendering = True
MainForm.Controls.Add(myScriptManager)
对于UpdatePanel:
With BeginBroadcastPanel
.ID = "BeginBroadcastPanel"
.Attributes.Add("style", "display:flex;flex-direction:column;justify-contents:center;align-items:center;")
'.UpdateMode = UpdatePanelUpdateMode.Conditional
'.ChildrenAsTriggers = True
End With
对于按钮:
With lblBroadcastPanelLoginButton
.ID = "lblBroadcastPanelLoginButton"
.Text = "LOG IN"
.Attributes.Add("style", "font-weight:bold;margin:20px;width:50%;text-align:center;cursor:pointer;font-size:20pt;background:lightgray;border-radius:4px;padding:10px 10px 10px 10px;border:0px solid darkgray;")
'.Attributes.Add("onclick", "__doPostBack('<%=BeginBroadcastPanel.ClientID %>', null);")
'Dim t As New AsyncPostBackTrigger
't.ControlID = lblBroadcastPanelLoginButton.ClientID
't.EventName = "Click"
'BeginBroadcastPanel.Triggers.Add(t)
End With
在上面的代码中,我在按钮上显示了dttm和测试变量。dttm正在递增,但测试变量没有递增。为什么会这样?发现问题:按钮缺少单击处理程序。添加AddHandler后,一切都开始了
Public test As Integer
Public dttm As DateTime = DateTime.Now
Dim b As New Button
With b
test = test + 1
.Text = dttm.ToString("MM/dd/yyyy HH:mm:ss") & " - " & test.ToString & " - " & Page.IsPostBack
End With
BeginBroadcastPanel.ContentTemplateContainer.Controls.Add(b)