467,858 Members | 1,706 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,858 developers. It's quick & easy.

How to generate readonly attribute correctly?

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
Jul 9 '06 #1
  • viewed: 1660
Share:
3 Replies
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" <ha*******@yahoo.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...
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

Jul 9 '06 #2
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" <re*************@monarchmed.comwrote in message
news:u3**************@TK2MSFTNGP03.phx.gbl...
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" <ha*******@yahoo.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...
>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


Jul 9 '06 #3
Yes, instead of getting a reference to the textbox, you can get a reference
to the <tdand 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" <ha*******@yahoo.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
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" <re*************@monarchmed.comwrote in message
news:u3**************@TK2MSFTNGP03.phx.gbl...
>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" <ha*******@yahoo.comwrote in message
news:eq**************@TK2MSFTNGP04.phx.gbl...
>>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



Jul 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jimbo | last post: by
5 posts views Thread by John Smith | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.