none
ASP.NET Web Forms FAQ: Bagaimana untuk mendaftarkan fungsi JavaScript pada Code-Behind? RRS feed

  • Diskusi Umum

  • Gunakan ResterStartupScript

    this.Page.ClientScript.RegisterStartupScript(this.GetType(),"alert","<script>alert(‘hello’);</script>");

     

    Gunakan Literal control,

     

    private void Button2_Click(object sender, System.EventArgs e) 
    { 
        string str; 
        str="<script language='JavaScript'>";        
        str+="selectRange()"; 
            str+="<script>"; 
        Literal1.Text=str; 
    }
     

    Thread terkait: http://forums.asp.net/p/981603/1257057.aspx#1257057 


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Jumat, 05 Agustus 2011 03.10
    Moderator