In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "asp.net operation _ javascript:confirm return value way", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "asp.net operation _ javascript:confirm return value" bar!
There are two ways to use confirm in asp.net:
1. Failure to use ajax,confirm will cause face refresh.
two。 Ajax is used and will not be refreshed
a. Instead of using ajax, you can do it with StringBuilder.
(1) asp.net uses StringBuilder to control the background operation _ javascript:confirm return value, which is cumbersome.
1. Background start event
StringBuilder sb = new StringBuilder (); sb.Append ("); sb.Append (" var val=window.confirm ('Are you surety'); "); sb.Append (" window.document.getElementById ('TextBox1'). Value=val; "); sb.Append (" _ doPostBack (' TextBox1',''); "); sb.Append ("); this.RegisterStartupScript (System.Guid.NewGuid (). ToString (), sb.ToString ())
two。 Foreground code:
The copy code is as follows:
3. Background event code for text box OnTextChanged= "TextBox1_TextChanged"
Protected void TextBox1_TextChanged (object sender, EventArgs e) {if (TextBox) (sender)). Text! = ") {if (TextBox) (sender)). Text.ToUpper () =" TRUE ") {/ / execute another event / method} if ((TextBox) (sender)). Text.ToUpper () =" FALSE ") {/ / cancel and execute another event / method}
This event can also be written as other method drivers. Just judge the value of TexBox1.
Note: this event is caused by AutoPostBack= "true" to refresh the page and the global variable is lost. It is best to use the session variable to hold the value that needs to be stored.
(2) if the method of background execution is determined by the foreground Javascript, there is an extra OnClientClick event. This method is the simplest.
Front desk button event
The copy code is as follows:
Just add it on the page
A.OnClick background event
B.OnClientClick event, confirm of javascript. Execute OnClick after you select OK. In the background is the event bt_DeleteButton_Click.
B: pages that use the Ajax control
The copy code is as follows:
ScriptManager.RegisterStartupScript (UpdatePanel1, UpdatePanel1.GetType (), "", "alert ('prompt'); if (confirm ('whether to continue with yes)) {alert (' continue to add on this page')} else {window.open ('productManage.aspx','_blank');}", true)
At this point, I believe you have a deeper understanding of the "asp.net operation _ javascript:confirm return value", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 284
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.