Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReadOnly DTC's

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
GB
Is it possible to make a textbox DTC read only? I have tried using textboxname.disable() but i'm passing a date into the textbox and when it's disabled the date is formatted in some very bizzare way.

I need the date to be displayed but not editable, a label doesn't support .value, i also need to be able to disable some other textboxes and drop downs in the same way depending on the users choice in a different drop down.

Think that makes sense. "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
If I need a textbox to be read only I right click the textbox DTC and choose properties and uncheck the enable box and that seems to work for me. You can view the textbox, but you cannot make changes. This works even if it is a date in the value of the textbox.
 
Doing that is the same as passing disable to the texbox. It still makes it disabled.

"i'm passing a date into the textbox and when it's disabled the date is formatted in some very bizzare way" "Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway" - Jim Davis (Garfield)
 
I know. I was trying to say that I can do it just fine with no problems and that it should work fine for you to do it that way. Are you sure you are passing the date in correctly? I just did it as:

function thisPage_onenter() {

txtDate.value = Date()

}

and it gives me the date Wed Sep 25 10:28:01 2002 if I enable it or disable it.
 
oh ok. Kind of. I'm using VBScript though:
<%
function GetDate()
DateInput.value = date()
end function
%>

if i use Javascript i don't get anything. Just a blank textbox. &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
This might be a silly question, but are you putting it between <SCRIPT RUNAT=Server LANGUAGE=JavaScript> </script>

<SCRIPT RUNAT=Server LANGUAGE=JavaScript>
function thisPage_onenter() {

Textbox1.value = Date()
}

</script>

 
yes it is a silly question and yes i am. i don't know if it's something to do with using Microsoft transaction Server or not? &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
Sorry, but sometimes you have to ask silly questions. If you put that code in the middle of vbscript it didn't give an error, but it gives a blank textbox, so I had to ask.

It has to be something besides the code then. If it has to do with you using microsoft transaction server, I have no idea, but I do know that the code you are using should be working correctly. I wish I could be more help.
 
You should be able to use the label, or a disabled textbox - or just <%=dtMyDate%> type inline code.

However, dates are odd beasts - they exist as either a string that looks like a date, or as a true date object.

If you create a 'true' date from vbscript (date()) then you can format it either via the formatDateTime() function, or by extracting each date part (Year, month, day) and stringing them together in whatever way you need. If you need the Month Names - you have to resort to building an string or array of names, and converting the month number to the appropriate month name.

DTC's only understand JavaScript functions (which are fairly thin for formatting purposes) BUT you can write a VBscript function in the web page and call that instead.
In a label dtc value property type:
=MyDateFormatFunction()

which is in VBScript:
Function MyDateFormatFunction()
'return todays date in long format
MyDateFormatFunction = formatDateTime(date(), vbLongDate)
End Function

Now, if the date comes from a database, and you are using a Recordset DTC - then the date is presented as a String. This can be annoying as you may not like its format, and it may not easily convert back to a true date for re-formatting. Furthermore, if you change to a different database, it may well present the date differently (typically dd/mm/yy in one, then mm/dd/yyyy in another).

There are many things that you could do. For example, you could:
- adjust the SQL to generate a nicely formatted date string
- adjust the RecordsetDTC code (_ScriptLibrary / RECORDSET.ASP) to return the raw (non-string) value from the database
- adjust the RecordsetDTC to allow you to bind-in a format function for the specified columns (which is what I did). So that column is always presented in the format of your choosing.

Hope this helps! (Content Management)
 
Thanks MerlinB i'd actually just found that out an hour earlier. lol. i used the formatdate function and placed that into a string and then the string into a disabled textbox. Your way is probably a little neater but either or works. Thanks. &quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top