473,406 Members | 2,956 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,406 software developers and data experts.

Creating a String based upon textbox value

Dear All,

I wish to have an ASP page that displays a predetermined date in the
middle of a string. I wish this date to be set in a seperate control
panel type page. I am hoping somebody could help me.

eg ...

A page called "Confirm.asp" has text ... "These prices are valid until
28th Feb 2006". I currently have to go and hard code the date in
whenever there is a need to change it.

I would like to be able to set this date from another page (eg
"SetDate.asp"), where I type the date in a textbox, click on an "OK"
button, then whenever "Confirm.asp" is opened in the future it picks up
the entered date.

Most form type of code I have found seems to want to email the value in
the textbox somewhere ... which is obviously not what I am after.

Many Thanks...
andym

Feb 8 '06 #1
7 2554
I assume from what you've written that this is not a rolling date (i.e.
today plus X days), or even the last day of this month? If so, then these
should both be calculatable in VBScript within the ASP code.

If it's a non-calculatable value then it strikes me that this needs to be
durable data held ideally in a database.

If you don't have access to a database then I guess you could write the
value entered in setDate.asp to a text file (beware file security
permissions - you don't want to open your file system up to ALL your
guests). The "Confirm.asp" file could first check to see if it's cached
this value in (say) the application cache, otherwise it would have to
retrieve it from the text file.

Feb 8 '06 #2
Griff,

thanks for your reply.

To answer your questions, there is no rolling date, it doesn't have to
be the end of the month - it is non-calculatable, and will be business
decision driven.

I don't have a database to work with. I just need that value stored so
it can be used as a point of reference when the "Confirm.asp" page is
opened.

I am guessing as it will be just a date then security is not an issue?
I no gripe if anybody wants to hack into the system and find a date.

Regards,

andym

Feb 8 '06 #3
I am guessing as it will be just a date then security is not an issue?
I no gripe if anybody wants to hack into the system and find a date.


What I meant here is that if you start allowing the internet guest account
write permissions to the file system then make sure you control it.
Otherwise it's very easy for someone to write an ASP code file with
malicious code in it and run it....
Feb 8 '06 #4
Thanks Griff..

The date will be added from an area of the website where you need a
password to access it. Hopefully that will limit it to only the two
people who do have access.

Any tips on how to knck this ting off? Any tuts on the net that would
help me?

Regards,

andym

Feb 9 '06 #5
andym wrote on 09 feb 2006 in microsoft.public.inetserver.asp.general:
he date will be added from an area of the website where you need a
password to access it. Hopefully that will limit it to only the two
people who do have access.

Any tips on how to knck this ting off? Any tuts on the net that would
help me?


Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the article
headers. <http://www.safalra.com/special/googlegroupsreply/>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 9 '06 #6

"andym" <ap******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Thanks Griff..

The date will be added from an area of the website where you need a
password to access it. Hopefully that will limit it to only the two
people who do have access.

Any tips on how to knck this ting off? Any tuts on the net that would
help me?
Here's a really simple way to implement abstracted storage of text:

<!-- begin displayexternaldate.asp -->
<html>
<body>
<span>
The externally stored date value (actually, just text) is:
<!-- #include file="datestorage.asp" -->. All this text
will be displayed inline, because HTML ignores white space.
</span>
</body>
</html>

<!-- end displayexternaldate.asp -->

The referenced file datestorage.asp contains only the date string.

Then overwrite the file datestorage.asp using an ASP page similar the
example I've included below.

Note that if the people authorized to use the overwrite.asp page have NT
accounts on the server (that are permitted to write files to the web
directory), you can set NTFS permissions on the overwrite.asp file that deny
access to the anonymous user, and will thus both force HTTP Auth, and run in
the context of the user that logs in. That would be the icing on your
security cake.

Otherwise the anonymous user will need NTFS permissions to create and change
files (not to be confused with IIS permissions to write to the directory,
which are unnecessary in this case.) If you're stuck with that, I would
suggest creating a separate directory for the date storage file, and grant
appropriate NTFS permissions to that directory, rather than your web app
directory, just to limit damage potential as much as possible. (Adjust path
values in examples as necessary.)

Hope this helps...

-Mark
<!-- begin overwrite.asp -->
<%
Dim NewDate
NewDate = Request.Form("NewDate")

' rudimentary protection against use of this to create executable
' code on the server
'
NewDate = Replace(NewDate, "<", "&gt;")

If Len(NewDate) > 0 then
' another rudimentary security/validity check
If Not IsDate(NewDate) Then
Response.Write "Invalid input: '" & NewDate & "' not a recognizable date."
Response.End
End If

Dim fso, oFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFile = fso.CreateTextFile(Server.MapPath("datestorage.asp "), True)
oFile.WriteLine(NewDate)
oFile.Close

Response.Write "Date file has been rewritten."
Response.End
End If

%>
<html>
<body>
<form action=# method=POST>
Enter a date: <input type=text name=NewDate /><br>
<input type=submit />
</form>
</body>
</html>
<!-- end overwrite.asp -->


Regards,

andym

Feb 11 '06 #7

Mark J. McGinty wrote:
"andym" <ap******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Thanks Griff..

The date will be added from an area of the website where you need a
password to access it. Hopefully that will limit it to only the two
people who do have access.

Any tips on how to knck this ting off? Any tuts on the net that would
help me?


Here's a really simple way to implement abstracted storage of text:

<!-- begin displayexternaldate.asp -->
<html>
<body>
<span>
The externally stored date value (actually, just text) is:
<!-- #include file="datestorage.asp" -->. All this text
will be displayed inline, because HTML ignores white space.
</span>
</body>
</html>

<!-- end displayexternaldate.asp -->

The referenced file datestorage.asp contains only the date string.

Then overwrite the file datestorage.asp using an ASP page similar the
example I've included below.

Note that if the people authorized to use the overwrite.asp page have NT
accounts on the server (that are permitted to write files to the web
directory), you can set NTFS permissions on the overwrite.asp file that deny
access to the anonymous user, and will thus both force HTTP Auth, and run in
the context of the user that logs in. That would be the icing on your
security cake.

Otherwise the anonymous user will need NTFS permissions to create and change
files (not to be confused with IIS permissions to write to the directory,
which are unnecessary in this case.) If you're stuck with that, I would
suggest creating a separate directory for the date storage file, and grant
appropriate NTFS permissions to that directory, rather than your web app
directory, just to limit damage potential as much as possible. (Adjust path
values in examples as necessary.)

Hope this helps...

-Mark
<!-- begin overwrite.asp -->
<%
Dim NewDate
NewDate = Request.Form("NewDate")

' rudimentary protection against use of this to create executable
' code on the server
'
NewDate = Replace(NewDate, "<", "&gt;")

If Len(NewDate) > 0 then
' another rudimentary security/validity check
If Not IsDate(NewDate) Then
Response.Write "Invalid input: '" & NewDate & "' not a recognizable date."
Response.End
End If

Dim fso, oFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFile = fso.CreateTextFile(Server.MapPath("datestorage.asp "), True)
oFile.WriteLine(NewDate)
oFile.Close

Response.Write "Date file has been rewritten."
Response.End
End If

%>
<html>
<body>
<form action=# method=POST>
Enter a date: <input type=text name=NewDate /><br>
<input type=submit />
</form>
</body>
</html>
<!-- end overwrite.asp -->


Regards,

andym


Mark,

many thanks for your reply and your example...

I shall put your advice into practise over the next couple of days.

Most appreciated,

Regards,

andym

Feb 13 '06 #8

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

Similar topics

3
by: Roberto Becerril | last post by:
Hi forum, i'm a little new in javascript and maybe you can help me. I have an html form and an icon, if i click on the icon, a new pop-up window is open and shows a list of numbers with a...
2
by: vivek | last post by:
Hello Every body, I am tring to make an array of server controls with array indes can change dynamically. But I was not able to get the refrence of the control outside the scope in which they...
4
by: Shiju Poyilil | last post by:
Hello EveryBody, I have a dropdownlist with some values as .net server controls & a button , on clicking a button i need to generate the choosen contorl dynamically. I am giving a small glimpse...
2
by: epigram | last post by:
I'm dynamically creating a number of radio buttons on my aspx page based upon data read from a db. Each radio button has autopostback turned on. I'm experiencing two problems. 1) I am reading...
1
by: Flack | last post by:
Hey guys, Here is whats happening. I have a StringBuilder, a TextBox, and a TabControl with one TabPage. On my main form, I created and displayed a fairly big maze. While the app is solving...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
4
by: Randy | last post by:
My situation is that I have a form on which a number of textboxes and comboboxes are added dynamically based on interaction with the user. As these controls are added, they are given names based on...
0
by: Gary W. Smith | last post by:
Hello, I have a simple form with a radio button group on it and I need to do some basic validation based upon which button is checked. Here is a little more detail. if button one is...
1
by: RobAMacAF | last post by:
How do I go about making a variable based on a string? For instance.... string test = "Bob"; System.Windows.Forms.TextBox test = new System.Windows.Forms.TextBox(); What I want to do is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.