主营业务:网站制作 网站优化 小程序制作 石家庄网站制作网站建设有限公司欢迎您!
石家庄闪云网络科技有限公司
客服热线15383239821
如何让自己的网站更有质量?

ASP.net中aspx与cs函数的互调

发布时间:2014/6/13 9:37:09

之前,因为不知道aspx中的script怎么调aspx.cs中的函数,无法操作GridView控件,无法读取控件数据集信息;因为不知道aspx.cs函数怎么调用aspx中script中的函数,无法设置<div>等的属性。通过互调,可以方便解决这两方面问题。

aspx前台的script函数,调用aspx.cs中后台函数:

aspx:

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

aspx.cs:

protected string BehindtFunction()

{

       //代码

       return "空";//需要有返回值

}

 

aspx.cs中后台函数,调用aspx前台的script函数:

aspx.cs:

protected stringBehindtFunction(object sender, EventArgs e)

{

       //代码

       ClientScript.RegisterStartupScript(this.GetType(), "clear", "<script>FrontFunction()</script>");

}

aspx:

<script type="text/javascript">
  function   FrontFunction()  
    {   

        mask.style.visibility = 'visible';
        Div2.style.visibility = 'visible';
        return false;
    }  
</script>

<div id="mask"></div>

 

上一篇: textbox文本框事件

相关新闻推荐

在线客服 : 服务热线:15383239821 电子邮箱: 27535611@qq.com

公司地址:石家庄市新华区九中街江西大厦4062

备案号:冀ICP备2022000585号-4