Alex Rivera | Logout

Setting the Textbox read only property to true using JavaScript

Asked 2009-11-18T21:48:08.000
19

How do you set the Textbox read only property to true or false using JavaScript in ASP.NET?

Edit
Report

1 Answer

0

it depends on how you trigger the event. the key you are looking is textbox.clientid.

x.aspx code

<script type="text/javascript">

   function disable_textbox(tid) {
        var mytextbox = document.getElementById(tid);
         mytextbox.disabled=false
   }
</script>

code behind x.aspx.cs

    string frameScript = "<script language='javascript'>" + "disable_textbox(" + tx.ClientID  ");</script>";
    Page.ClientScript.RegisterStartupScript(Page.GetType(), "FrameScript", frameScript);
answered 2009-11-18T22:04:22.153

Your Answer