ASP.net中aspx與cs函數的互調


轉載自:http://www.2cto.com/kf/201209/152898.html

aspx前台的script函數,調用aspx.cs中后台函數

aspx:

<script type="text/javascript">
    function FrontFunction()
    {
        var RetStr=<%=BehindtFunction()%>;
        alert(RetStr);  
    }  
</script>

aspx.cs:

protected string BehindtFunction(object sender, EventArgs e)
{
    //todo:執行代碼
    return "";//需要有返回值
}

aspx.cs中后台函數,調用aspx前台的script函數

aspx.cs:

protected string BehindtFunction(object sender, EventArgs e)
{
    //代碼
    ClientScript.RegisterStartupScript(this.GetType(), "clear", "<script>FrontFunction()</script>");
    return "";
}

aspx:

<script type="text/javascript">
    function FrontFunction()
    {
        mask.style.visibility = 'visible';
        Div2.style.visibility = 'visible';
    }   return false;
</script>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM