How to generate readonly attribute correctly?

Discussion in 'ASP .Net Datagrid Control' started by Hamed, Jul 9, 2006.

  1. Hamed

    Hamed Guest

    Hello

    I have a DataGrid object in my ASP.NET page that has the following template
    column. When I put the "readonly" attribute in the INPUT tag, it generates
    readonly="".

    <asp:TemplateColumn HeaderText="Kg Price" HeaderStyle-Width="5%">
    <ItemTemplate><INPUT class="ep" id=kf readOnly value='<%#
    DataBinder.Eval(Container, "DataItem.KgFee") %>' name=kf
    runat="server"></ItemTemplate>
    </asp:TemplateColumn>


    As there is a lot of rows in the DataGrid, I want to remove three unneeded
    attributes:
    1- I want to remove the [=""] from the end of generated "readonly" attribute
    in the page.
    2- Is it possible to make CSS codes for ReadOnly attribute?
    3- Is it possible to remove the type="text" part of the INPUT tag or move it
    to the CSS code?

    Bests
    Hamed
     
    Hamed, Jul 9, 2006
    #1
    1. Advertising

  2. Hamed

    Hamed Guest

    The page has some controls on the text and use it for some calculations. Is
    it possible to get the value of some non INPUT tags such as the <td>my
    integer value</td>?

    I am using some JavaScript code like the following:

    function kp()
    {
    var number=document.activeElement.id.substr(j.index,k);

    var ctl = 'gd__ctl' + number + '_kf';
    var myValue = Form1.all.namedItem(ctl);

    //do some manipulation with myValue.
    ...

    }




    "Eliyahu Goldin" <> wrote in message
    news:...
    > 2. No, not in standard CSS. But you can make a simple javascript that will
    > find all inputs that need to be readonly and set their readOnly property
    > to true.
    >
    > 3. Absolutely no.
    >
    > Just wandering, may be you could use labels or literal content instead of
    > readonly textboxes?
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    > "Hamed" <> wrote in message
    > news:...
    >> Hello
    >>
    >> I have a DataGrid object in my ASP.NET page that has the following
    >> template column. When I put the "readonly" attribute in the INPUT tag, it
    >> generates readonly="".
    >>
    >> <asp:TemplateColumn HeaderText="Kg Price" HeaderStyle-Width="5%">
    >> <ItemTemplate><INPUT class="ep" id=kf readOnly value='<%#
    >> DataBinder.Eval(Container, "DataItem.KgFee") %>' name=kf
    >> runat="server"></ItemTemplate>
    >> </asp:TemplateColumn>
    >>
    >>
    >> As there is a lot of rows in the DataGrid, I want to remove three
    >> unneeded attributes:
    >> 1- I want to remove the [=""] from the end of generated "readonly"
    >> attribute in the page.
    >> 2- Is it possible to make CSS codes for ReadOnly attribute?
    >> 3- Is it possible to remove the type="text" part of the INPUT tag or move
    >> it to the CSS code?
    >>
    >> Bests
    >> Hamed
    >>

    >
    >
     
    Hamed, Jul 9, 2006
    #2
    1. Advertising

  3. 2. No, not in standard CSS. But you can make a simple javascript that will
    find all inputs that need to be readonly and set their readOnly property to
    true.

    3. Absolutely no.

    Just wandering, may be you could use labels or literal content instead of
    readonly textboxes?

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    "Hamed" <> wrote in message
    news:...
    > Hello
    >
    > I have a DataGrid object in my ASP.NET page that has the following
    > template column. When I put the "readonly" attribute in the INPUT tag, it
    > generates readonly="".
    >
    > <asp:TemplateColumn HeaderText="Kg Price" HeaderStyle-Width="5%">
    > <ItemTemplate><INPUT class="ep" id=kf readOnly value='<%#
    > DataBinder.Eval(Container, "DataItem.KgFee") %>' name=kf
    > runat="server"></ItemTemplate>
    > </asp:TemplateColumn>
    >
    >
    > As there is a lot of rows in the DataGrid, I want to remove three unneeded
    > attributes:
    > 1- I want to remove the [=""] from the end of generated "readonly"
    > attribute in the page.
    > 2- Is it possible to make CSS codes for ReadOnly attribute?
    > 3- Is it possible to remove the type="text" part of the INPUT tag or move
    > it to the CSS code?
    >
    > Bests
    > Hamed
    >
     
    Eliyahu Goldin, Jul 9, 2006
    #3
  4. Yes, instead of getting a reference to the textbox, you can get a reference
    to the <td> and use it's innerText property. In this case you might not need
    an item template in the first case. Just make a BoundColumn bound to KgFee.
    The values will go straight inside the <td>s. The grid will render as a
    table and you should be able to loop through the rows and cells collections
    in javascript. Or you can consider replacing the grid with a repeater with
    item template something like
    <tr>
    <td class="ep" id=kf name=kf >'<%# DataBinder.Eval(Container,
    "DataItem.KgFee") %>'</td>
    </tr>

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    "Hamed" <> wrote in message
    news:%23$...
    > The page has some controls on the text and use it for some calculations.
    > Is it possible to get the value of some non INPUT tags such as the <td>my
    > integer value</td>?
    >
    > I am using some JavaScript code like the following:
    >
    > function kp()
    > {
    > var number=document.activeElement.id.substr(j.index,k);
    >
    > var ctl = 'gd__ctl' + number + '_kf';
    > var myValue = Form1.all.namedItem(ctl);
    >
    > //do some manipulation with myValue.
    > ...
    >
    > }
    >
    >
    >
    >
    > "Eliyahu Goldin" <> wrote in message
    > news:...
    >> 2. No, not in standard CSS. But you can make a simple javascript that
    >> will find all inputs that need to be readonly and set their readOnly
    >> property to true.
    >>
    >> 3. Absolutely no.
    >>
    >> Just wandering, may be you could use labels or literal content instead of
    >> readonly textboxes?
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer & Consultant
    >> Microsoft MVP [ASP.NET]
    >>
    >> "Hamed" <> wrote in message
    >> news:...
    >>> Hello
    >>>
    >>> I have a DataGrid object in my ASP.NET page that has the following
    >>> template column. When I put the "readonly" attribute in the INPUT tag,
    >>> it generates readonly="".
    >>>
    >>> <asp:TemplateColumn HeaderText="Kg Price" HeaderStyle-Width="5%">
    >>> <ItemTemplate><INPUT class="ep" id=kf readOnly value='<%#
    >>> DataBinder.Eval(Container, "DataItem.KgFee") %>' name=kf
    >>> runat="server"></ItemTemplate>
    >>> </asp:TemplateColumn>
    >>>
    >>>
    >>> As there is a lot of rows in the DataGrid, I want to remove three
    >>> unneeded attributes:
    >>> 1- I want to remove the [=""] from the end of generated "readonly"
    >>> attribute in the page.
    >>> 2- Is it possible to make CSS codes for ReadOnly attribute?
    >>> 3- Is it possible to remove the type="text" part of the INPUT tag or
    >>> move it to the CSS code?
    >>>
    >>> Bests
    >>> Hamed
    >>>

    >>
    >>

    >
    >
     
    Eliyahu Goldin, Jul 9, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    4,203
  2. Matt
    Replies:
    2
    Views:
    19,155
  3. Hamed
    Replies:
    3
    Views:
    702
    Eliyahu Goldin
    Jul 9, 2006
  4. bruno modulix

    readonly class attribute ?

    bruno modulix, Mar 15, 2005, in forum: Python
    Replies:
    4
    Views:
    643
    Bruno Desthuilliers
    Mar 15, 2005
  5. Jonathan Hyatt
    Replies:
    1
    Views:
    2,146
    Jonathan Hyatt
    Jun 8, 2004
Loading...

Share This Page