簡體   English   中英

需要使用C#調用jQuery(window).load(function())

[英]Need to call jQuery (window).load(function ()) using c#

我需要使用C#調用(window).load(function ()) 無論如何,我能做到這一點。

注冊您要使用任何腳本RegisterStartupScript

protected void Page_Load(object sender, EventArgs e)
{
    // Define the name and type of the client scripts on the page.
    String csname1 = "PopupScript";
    Type cstype = this.GetType();

    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;

    // Check to see if the startup script is already registered.
    if (!cs.IsStartupScriptRegistered(cstype, csname1))
    {
        StringBuilder cstext1 = new StringBuilder();
        cstext1.Append(@"$(document).ready(function() {
                                // Handler for .ready() called.
                              });");

        cs.RegisterStartupScript(cstype, csname1, cstext1.ToString(), true);
    }
}

沒有! 這是不可能的。 您不能在服務器端腳本中使用客戶端對象。 有關更多信息,請閱讀- 將JavaScript與ASP.NET一起使用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM