javascript方法获取后台控件调用、传参

1) 后台代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace JSDEmo
{
    public partial class _Default : System.Web.UI.Page
    {
        private TextBox txtDemo;
        private Button btnDemo;
        protected void Page_Load(object sender, EventArgs e)
        {
            txtDemo = new TextBox();
            txtDemo.ID = "txtDemo";
            btnDemo = new Button();
            btnDemo.ID = "btnDemo";
            btnDemo.Text = "Demo";
            this.FindControl("ContentPanel").Controls.Add(txtDemo);
            btnDemo.OnClientClick = string.Format("return demo('{0}');",txtDemo.ClientID);
            this.FindControl("contentPanel").Controls.Add(btnDemo);
        }
    }
}

2) 前代代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="JSDEmo._Default" %>



    
    


    


你可能感兴趣的:(javascript,javascript,c#后台控件调用js)