Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > How to generate readonly attribute correctly?

Reply
Thread Tools

How to generate readonly attribute correctly?

 
 
Hamed
Guest
Posts: n/a
 
      07-09-2006
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


 
Reply With Quote
 
 
 
 
Hamed
Guest
Posts: n/a
 
      07-09-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-09-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-09-2006
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" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to generate readonly attribute correctly? Hamed ASP .Net 3 07-09-2006 01:23 PM
readOnly attribute doesn't work for drop down list? Matt HTML 2 06-29-2004 12:22 AM
problem to disable or enable READONLY attribute Matt HTML 1 06-22-2004 01:49 AM
ASP.NET Readonly panel function with readonly checkbox, readonly radiobutton Jonathan Hyatt ASP .Net Web Controls 1 06-08-2004 07:42 PM



Advertisments