ajax|asp.net| Script
The atlas July CTP has been used in recent projects, and since Atlas was officially renamed, the Beta and Beta2 two editions have been rolled out continuously, but I've been watching because the beta version is unstable and the upgrades are too cumbersome. A day by chance to see this essay Yangdan, suddenly found that ScriptManager can register in the client part of the refresh UpdatePanel registered after the start of the javascript! This is a problem that has plagued me for a long time! This allows you to use the JavaScript pop-up dialog box without using UpdatePanel, or to enable the control's start script to execute when you develop a server control that uses JavaScript scripts. Such original and UpdatePanel incompatible controls can easily be changed to Ajax enabled ^_^.
However, it is puzzling that do not know what to consider, RegisterStartupScript function is actually implemented for the class static function, but there is no ScriptManager UpdatePanel can not perform Ah, so you need to hit a few more words! Also, note that the first parameter is an instance of UpdatePanel, and if there is more than one UpdatePanel in the page, if each UpdatePanel UpdateMode is "always" [Default value], Then you can use that UpdatePanel instance as a parameter, and if each Updaepanel updatemode=conditional, then you must use the UpdatePanel that is being updated as an argument so that the script will work. Here's a simple example of what I've done:
Page marks
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Default.aspx.cs" inherits= "_default"%>
untitled page
LinkButton
LinkButton
Please waiting the retrieving data from server
Code
Using System;
Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
}
protected void LinkButton1_Click (object sender, EventArgs e)
{
System.Threading.Thread.Sleep (1000);
TextBox1.Text = DateTime.Now.ToLongTimeString ();
TextBox2.Text = TextBox1.Text;
String js = "alert (' OK button1 clicked! ')";
Microsoft.Web.UI.ScriptManager.RegisterStartupScript (UpdatePanel2, this. GetType (), "btn1clicked", JS, True);
}
protected void Linkbutton2_click (object sender, EventArgs e)
{
System.Threading.Thread.Sleep (900);
TextBox2.Text = DateTime.Now.ToLongTimeString ();
TextBox1.Text = TextBox2.Text;
String js = "alert (' OK button 2 clicked! ')";
Microsoft.Web.UI.ScriptManager.RegisterStartupScript (UpdatePanel2, this. GetType (), "btn2clicked", JS, True);
}
BTW, I found a problem when using, do not know is a bug or I use improper, I found in the debug updatepanel.isinpartialrendering value is always false! Hope to have an expert to guide:).
Http://www.cnblogs.com/dajianshi/archive/2006/11/20/565524.html