DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> AJAX入門 >> AJAX詳解 >> 關天asp.net ajax beta中在updatepnael中注冊腳本的解決方案
關天asp.net ajax beta中在updatepnael中注冊腳本的解決方案
編輯:AJAX詳解     

最近也在看一些ASP.Net AJax 的資料,在網上看到很多人都在問如何在updatepanel中注冊腳本,我也試了一下,不過總是不行,就看了好多資料,最後才知道自己沒有完全理解 ScriptManager.RegisterClientScriptBlock(Control control,Type type,string key, string script,bool addScriptTags),其中的各個參數。(注:RegisterClIEntScriptBlock是 ScriptManager的一個靜態方法)
          參數詳解:
                           control (Control) :這個參數是注冊腳本塊的控件.如果你是在updatepanel中注冊時,即updatepanel  (應該寫updatepanel的ID).
                            type (Type)        :這個參數是注冊腳本塊控件的類型,即updatepanel的類型。
                           key (String)         :這個參數是腳本酷塊的惟一標識(關鍵字)
                           script (String)      :這個參數是要注冊的腳本字符串.
                         addScriptTags (Boolean) :這個參數表示是否要在您的字符串兩邊使用“<script>”和“</script>”包圍起來.

然後這是我寫的一個簡單的例子:
               
  Html代碼:
                                  <html XMLns="http://www.w3.org/1999/xHtml">
<head runat="server">
    <title>Untitled Page</title>
    <link href="/ASPnet_client/System_Web/2_0_50727/CrystalReportWebFormVIEwer3/CSS/default.CSS"
        rel="stylesheet" type="text/CSS" />
</head>
<body>
    <form id="form1" runat="server">
        <ASP:ScriptManager ID="ScriptManager1"   runat="server" />
        <ASP:UpdatePanel ID="UpdatePanel1" runat="server" >
            <ContentTemplate>
                <ASP:Button ID="Button1" runat="server" Text="Button" />
            </ContentTemplate>
        </ASP:UpdatePanel>
    </form>
</body>
</Html>

CS代碼:
    protected void Button1_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterClIEntScriptBlock(UpdatePanel1, typeof(UpdatePanel), "test", "alert('test');", true);

    }

     以上是我的理解,如果有不正確的地方,請大家糾正,我先放到首頁,其實沒有什麼技術含量,主要是用來讓那些還不知道如何注冊的朋友看到.過後dohu可以刪了。
http://www.cnblogs.com/sunlife/archive/2006/11/05/550520.Html

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved