C# 更新面板、确认按钮和更新进度don';他似乎不在一起工作
目前,我没有运气尝试让他们三个一起工作,我只有运气与updatepanel和更新进展没有任何确认按钮到目前为止C# 更新面板、确认按钮和更新进度don';他似乎不在一起工作,c#,javascript,jquery,asp.net,C#,Javascript,Jquery,Asp.net,目前,我没有运气尝试让他们三个一起工作,我只有运气与updatepanel和更新进展没有任何确认按钮到目前为止 <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnEnter" runat="server" Text="Update" Width="180" Style="margin-left:157px;"
OnClick="btnEnter_Click"
CssClass="button-success pure-button"/>
<asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server"
TargetControlID="btnEnter"
ConfirmText="Do you want to see submit?"
ConfirmOnFormSubmit="false">
</asp:ConfirmButtonExtender>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="overlay"></div>
<div class="modal">
<h2>Please Wait.....</h2>
<img alt="Loading..." src="/Images/loading.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
使用客户端,您可以更轻松、更高效地执行此操作,如下所示:
您只需要在
中添加onclientclick属性,尝试使用jquery验证表单,然后在验证成功时抛出确认对话框
function ValidateForm(){
//validation
if(succeeded){
return confirm('are you sure?');
}else{
return false
}
}
$(document).ready(function(){
$('#' + '<%= btnEnter.ClientID %>').click(function(){
return ValidateForm();
});
});
函数ValidateForm(){
//验证
如果(成功){
返回确认(“您确定吗?”);
}否则{
返回错误
}
}
$(文档).ready(函数(){
$('#'+'')。单击(函数(){
返回ValidateForm();
});
});
那么到底是什么问题呢?基本上,当我执行确认按钮时,它会破坏更新面板,而其中什么都不起作用,我以前使用过javascript确认,但我意识到我正在提交表单,然后检查表单的有效性。您使用什么触发更新面板上的回发?我正在使用按钮postback@MBiggs看看这个我已经说过我以前做过了但我有验证的问题,因为javascript在我检查表单是否有效之前运行。我还是很感激你的回答
<asp:Button ID="btnEnter" runat="server" Text="Update"
Width="180" Style="margin-left:157px;"
OnClick="btnEnter_Click"
CssClass="button-success pure-button"
OnClientClick="return confirm('Do you want to see submit?');"/>
protected void btnEnter_Click(object sender, EventArgs e)
{
if(Page.IsValid )
{
ScriptManager.RegisterStartupScrip(UpdatePanel1, this.GetType(),
"confirm", "return confirm('Are you sure you want to submit?');", true);
}
}
function ValidateForm(){
//validation
if(succeeded){
return confirm('are you sure?');
}else{
return false
}
}
$(document).ready(function(){
$('#' + '<%= btnEnter.ClientID %>').click(function(){
return ValidateForm();
});
});