0

I have a hidded textbox and Imagebutton.For avoiding the Postback i am trying to make textbox visible on click of the image button using javascript.But textbox is not showing on click of the image button,Instead image btton is moving. What could be wrong here in this code.

Appreciate ur help

  <asp:TextBox ID="TextBox2" text="From:" style=" visibility: hidden"  runat="server"  BackColor="#999999" BorderColor="Black" BorderStyle="Double"></asp:TextBox>

 <asp:ImageButton ID="ImageButton2" runat="server" BackColor="#99CCFF" 
 BorderColor="#84C1FF" BorderStyle="Outset" OnClientClick="MJavascriptFunction();return false;"  Height="35px" 
ImageUrl="search11.png" Width="56px" />

<script type="text/javascript">

   function MJavascriptFunction(obj) {
       var theControl = document.getElementById("<%=Textbox2.ClientID %>");

       theControl.style.display = "block";

   }

  </script>

1 Answer 1

2

Change

theControl.style.display = "block";

To

theControl.style.visibility="visible";

Example

In your Code you set the visiblity option to "hidden", So you need to use the same property in javscript

Alternatively you can change the HTML inline CSS to style="display:none".

Example

Sign up to request clarification or add additional context in comments.

1 Comment

@abcdshsu, if my answer solved your problem then it would be nice if you mark it as the answer :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.