473,224 Members | 1,582 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,224 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 1830
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.