Want to make the visibility true from client side of the control which made invisible from server side

前端 未结 3 1935
庸人自扰
庸人自扰 2021-01-20 17:33

I have a text box in a page. Whose visibility is set false from the server side. Now I want to make it visible from client side by using java-script. (Any post back or parti

3条回答
  •  半阙折子戏
    2021-01-20 18:00

    If you set the control visible=false it will not render at client side, But there is a tricky solution, that will accomplish the same thing.

    In your page load, where you are set Visible=false, you can set the style to display:none

    protected void Page_Load(object sender, EventArgs e)
    {
       TextBox1.Attributes.Add("style", "display:none");
    }
    

    It will render the control in client side, but user can't see and then you can visible the control in Javascript function to set style Diplay:block, LIKE...

    document.getElementById('<%=TextBox2.ClientID %>').style.display = 'block';
    

提交回复
热议问题