enable a textbox

asp India
  • 14 years ago

    hi friends
    i am using asp.net with c#
    i need to enable a textbox when a checkbox is clicked so how to do it
    plz do reply me to the earliest
    looking forward for ur reply
    i need to handle it using javascript




  • 14 years ago

    hey here is my coding

    //javascript
    function Enabledtxt()
            {
            
            if(document.frmNewsCreation.chkScrollNews.checked)
                {
                    alert("true");
                    document.frmNewsCreation.txtScrollSpeed.enabled=true;
                    document.frmNewsCreation.txtScrollSpeed.focus();
                }
            else
                {
                    alert("false");
                    document.frmNewsCreation.txtScrollSpeed.enabled=false;
                }
               return true;
            }  


    //html
    <asp:CheckBox ID="chkScrollNews" runat="server" Text="(Yes/No)" TabIndex="13"/>
    <asp:TextBox ID="txtScrollSpeed" runat="server" CssClass="tbox" onblur="BLOCKED SCRIPTeBlur(this);"
                                                                            onfocus="BLOCKED SCRIPTeFocus(this);" size="35" Width="50px" MaxLength="1" TabIndex="14" ></asp:TextBox>

    //codebehind in c#
    this.chkScrollNews.Attributes.Add("Onclick", "if(!Enabledtxt()) {return false;}");

    but still not getting it




























  • 14 years ago

    Hi Gayatri,

    Well you should use:  document.frmNewsCreation.txtScrollSpeed.disabled=true; or disabled=false.
    I think then it will start working. But now you should change your program logic a little as it is negation what is happening here.

    Regards
    Udai K

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Nine people can't make a baby in a month.” - Fred Brooks