www.webdeveloper.com
Results 1 to 2 of 2

Thread: Modifying ASP.NET Form elements with Javascript

Hybrid View

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Question Modifying ASP.NET Form elements with Javascript

    Hello all,



    I'm fairly new to ASP and Javascript.

    I'd like to change some properties of ASP Form Elements via Javascript and I am having a very difficult time doing so. The element is defined as:

    Code:
    <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
    But Im not having any luck modifying it with Javascript like this:

    Code:
    function enableFields() {
        document.form1.txtFirstname.disabled = false;
    }
    Can anyone shed some light on this for me? One thing I noticed is that (At least in VS2010 intellisense) the elemtn doesn't seem to have a disabled attribute like a standard HTML

    Code:
    <Input type="text" id="text1" disabled="true">
    Thanks in advance for helping!

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Code:
    function enableFields() {
        document.getElementById('txtFirstname').removeAttribute('disabled');
    }
    regarding the HTML
    Code:
    <input type="text" id="text1" disabled="true">
    This not quite standard. It is not incorrect, but it is not standard. Should be:
    Code:
    <input type="text" id="text1" disabled="disabled">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles