473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
3 1834
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fred K. | last post by:
Hi, I have form text fields that have the attribute readonly. I wish to use a javascript (invoked by a button on my page) to erase the values and set the readonly attribute to false. How do I...
1
by: Jack | last post by:
Hi, I have a asp page where a checkbox, when clicked will disable all text boxes associated with the page. The following is a part of a code for the checkbox with its name and readonly...
3
by: Jack | last post by:
Hi, I am trying to use the following code to make the save button invisible in the asp form when the checkbox is either on or the session variable has a particular value. THE CODE IS AS FOLLOWS:...
3
by: Matt | last post by:
I want to know if readOnly attribute doesn't work for drop down list? If I try disabled attribute, it works fine for drop down list. When I try text box, it works fine for both disabled and...
2
by: upersson | last post by:
Hi! When accessing my web page I build up the javascript and html dynamically. Depending on an parameter I want to set all the fields (input tags) readonly. How do I do this? Of course I can...
2
by: Alan | last post by:
Hi all, I have one class including one collection. I use propertygrid to display and edit its properties. I'm trying to use reflection to change the status of one element to be readonly, for...
7
by: Jimbo | last post by:
Hi, I am trying to set the readonly attribute of a text input tag dynamically from javascript. The input element already exists in the form and I want to make it readonly when a particular...
5
by: John Smith | last post by:
Is it possible to set DataGrid's ReadOnly property to True/False at runtime? An example: <asp:datagrid id="dg1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundColumn...
0
by: Bogdan | last post by:
Hi, I have a table adapter whose main query returns columns from multiple tables. The query calls a stored procedure which uses JOINs (or correlated subqueries - I get the same results in both...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.