473,225 Members | 1,266 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,225 software developers and data experts.

I need a "non user-editable" text field

Hi there,

I have a text box which will receive its value from a pop-up date picker.
The user should not be able to edit this field with the keyboard or mouse.

I am using ASP.NET. If I set the readonly property of the textbox to true,
it won't let the user change it and it can receive its value from the pop-op
calendar, just what I need. Problem is, after a postback, value is lost.

So I think Javascript may come to the rescue here. Is there a way to make a
field "non user-editable" without setting the "readonly" attribute? Maybe a
trick to make the field reject focus?

Many thanks in advance,

-Benton


Mar 3 '06 #1
7 10230
Benton said the following on 3/3/2006 6:15 PM:
Hi there,

I have a text box which will receive its value from a pop-up date picker.
The user should not be able to edit this field with the keyboard or mouse.
Then use a hidden field.
I am using ASP.NET.
Irrelevant.
If I set the readonly property of the textbox to true, it won't let the
user change it and it can receive its value from the pop-op calendar, just
what I need. Problem is, after a postback, value is lost.
Then use a hidden field.
So I think Javascript may come to the rescue here. Is there a way to make a
field "non user-editable" without setting the "readonly" attribute? Maybe a
trick to make the field reject focus?


Use a hidden field.....

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 4 '06 #2
VK

Benton wrote:
Hi there,

I have a text box which will receive its value from a pop-up date picker.
The user should not be able to edit this field with the keyboard or mouse.

I am using ASP.NET. If I set the readonly property of the textbox to true,
it won't let the user change it and it can receive its value from the pop-op
calendar, just what I need. Problem is, after a postback, value is lost.

So I think Javascript may come to the rescue here. Is there a way to make a
field "non user-editable" without setting the "readonly" attribute? Maybe a
trick to make the field reject focus?


As suggested use hidden field to store the actual value. Use a DHTML
widget to display non-editable (but still selectable) data. Make you
date widget to set both hidden field value and innerHTML value of
pseudo-input. Something like:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<style type="text/css">
..inputText {
font: 0.8em Tahoma,Geneva, sans-serif;
margin: 5px 5px;
padding: 2px 2px;
width: 20ex;
height: auto}

..pseudoInput {
display: -moz-inline-box;
display: inline-block;
font: 0.8em Tahoma, Geneva, sans-serif;
width: 20ex;
height: auto;
margin: 5px 5px;
padding: 1px 2px;
border: thin inset}
</style>
</head>

<body bgcolor="#FFFFFF">
<form method="post" action="">
<fieldset>
<legend>Test</legend>
<input type="text" name="txt" value="01.01.1970" class="inputText">
<span id="dateView" class="pseudoInput">01.01.1970</span>
<input type="hidden" name="date">
</fieldset>
</form>

</body>
</html>

Mar 4 '06 #3
Benton wrote:
Is there a way to make a
field "non user-editable" without setting the "readonly" attribute?


Why would you need to? What's wrong with the readonly attribute?
Mar 4 '06 #4
VK

TheBagbournes wrote:
What's wrong with the readonly attribute?


Asome. There is nothing wrong with it.

There is something wrong with people not reading docs through
(shamefully pointing to myself) :-)

Mar 4 '06 #5

"Randy Webb" <Hi************@aol.com> escribió en el mensaje
news:d5******************************@comcast.com. ..
I have a text box which will receive its value from a pop-up date picker.
The user should not be able to edit this field with the keyboard or
mouse.
Then use a hidden field.


Please excuse my newbiness but if the field is not visible, the the user
would not get any feedback on the value returned by the date picker. Sure I
am missing something.

Regards,

-Benton

Mar 4 '06 #6
Benton said the following on 3/4/2006 1:46 PM:
"Randy Webb" <Hi************@aol.com> escribió en el mensaje
news:d5******************************@comcast.com. ..
I have a text box which will receive its value from a pop-up date picker.
The user should not be able to edit this field with the keyboard or
mouse.

Then use a hidden field.


Please excuse my newbiness but if the field is not visible, the the user
would not get any feedback on the value returned by the date picker. Sure I
am missing something.


You say you are using a popup date picker. Fine. When the date picker
puts the value in the text field then you also have it put it in a span
element to display it to the user. Then, the user gets feedback, they
can't change it, and your hidden field gets the value. You could even
style the span to *look* like an input field.

Without seeing your date picker, and how it sets the hidden field, I can
only guess at how to tell you to do the above though. The simplest way
might be for the date picker to call a function in the opener window
that would set it:

opener.setDateValue(dateValueFromPicker);

And then in the opener:

function setDateValue(dateValue){
document.forms['formID'].elements['hiddenFieldName'].value = dateValue;
document.getElementById('spanID').innerHTML = dateValue;
}
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 4 '06 #7
>>>> I have a text box which will receive its value from a pop-up date
picker. The user should not be able to edit this field with the
keyboard or mouse.

You say you are using a popup date picker. Fine. When the date picker puts
the value in the text field then you also have it put it in a span element
to display it to the user. Then, the user gets feedback, they can't change
it, and your hidden field gets the value. You could even style the span to
*look* like an input field.


It works beautifully. Thanks to all of you guys for your help.

Regards,

-Benton

Mar 6 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Adrian Parker | last post by:
For some reason when I call validateFields before .Update (see below), I get this error: "Consumer's even handler called a non-reentrant method in the provider" However if I comment out the...
14
by: mirnazim | last post by:
Hi, There are great Python Web Application Framework. But most of them are meant for content oriented web apps. Is there something that can ease the development of application that are not...
15
by: Sander Tekelenburg | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The HTML specs speak of "replaced" and "non-replaced" elements, yet for the life of me I can't find an explanation of what "replaced" is supposed...
0
by: Robert Oschler | last post by:
I have a database table with a field that is indexed as a "full-text" search, since I want the capabiity. However, I also want the ability to quickly retrieve records from that table that are ins...
0
by: Brent | last post by:
If my field has something like this: 1. dez 2. eft 3. 4. hgt 5. Is there any way to put the non-blank fields on top, sorted alphabetically A-Z, and the blank fields on bottom in...
5
by: mabond | last post by:
Hi all This question is one of "theory" rather than a search for the specifics of a solution. I need some pointers as to how to proceed with my project. Here goes. My application allows the...
0
by: olimpia | last post by:
Hello, I am getting back to programming after many many years. Never work with Basic and now I am trying to work on a little project using Visual Basic.NET 2003 to verify info (at least 10 chars)...
5
by: Aneesh Pulukkul[MCSD.Net] | last post by:
How to convert a "Non Serializable" object to byte array. The object is a dynamically created Excel workbook. As per my understanding an object can be written and read from a stream Only if it's...
1
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have Mobile site that I'm building. My problem is that all of my pages are built as Mobile ASPX pages, but occasionally, I need to use controls which are not mobile. Most specifically, the...
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...
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...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.