请在纽伦加添以下内容:
button.OnClientClick = "return ConfirmThis();";
然后,需要增加公司。 本职能如下:
Page.ClientScript.RegisterScriptBlock(GetType(), "ConfirmThis",
@"function ConfirmThis() {
if(condition) { //where condition checks the bfound element.
return confirm(""Are you sure you want to delete this?"");
}
return true;
}");
采取这种做法,你会再次试图尝试,并能够测试 j版中客户一方的found状态。 如果<代码>bfound 价值储存在<条码>文本箱条码>或<条码>上。 如果<代码>bfound 当你创建该网页时,你可以将其注入<代码>。 直接通过<代码> 1. 确认代码>作为参数发挥作用。
Edit in response to your edit:
在试图从用户那里获得确认时,你有两个选择:
- Using client side logic that is already sent to the browser to perform the confirm. This is the example that I have given above.
- The "Other" option is to send the page back with a modal dialog, or using the confirm box. You will then get the user s confirmation back in a completely new postback to the server. So you ll need to rethink your logic to be able to temporarily store the information from the first post back and wait for the second post back to finalize the desired action.
在这两个例子中,第一种选择是清洁的,不需要临时记忆,使用户不必再加回。
由于这两种选择都要求你重订要求确认书的逻辑,如果我尽可能试图改变显示确认方言所需的逻辑,以便能够在客户的计算机上用javascript进行。
www.un.org/Depts/DGACM/index_spanish.htm 是否有任何办法可以预先计算成像变数,或至少向客户发送足够的信息。
If you still feel like using option 2 after all of my pleading:
使用以下代码(基于 http://www.dotnetspider.com/resources/1521-How-quest-Postback- from-Javascript.aspx:
if(bfound)
{
//save all the information you need in temporary information
ViewState["InformationINeedToFinishAfterPostback"] = ImportantInformation;
Page.ClientScript.RegisterScriptBlock(GetType(), "postbackmethod", Page.ClientScript.GetPostBackEventReference(this, "MyCustomArgument"));
Page.ClientScript.RegisterStartupScript(GetType(), "startupconfirm",
@"if(confirm(""are you sure?"") {
__doPostBack( __Page , MyCustomArgument );
}");
}
现在处理背后问题,在您的网页上添加以下代码:
if(Request("__EVENTARGUMENT") == "MyCustomArgument")
{
ImportantInformation = (CastToAppropriateType)ViewState["InformationINeedToFinishAfterPostback"];
//finalize the desired action here.
}
<><>But> 我仍建议第一个选择。 但是,现在,你需要两种选择。 此外,我也试过这一守则,因此,你不得不面对同学问题,但你却走上正轨。