Inputbox always with a date on open

Hello,
I have created a input box with the following code.
But every time it's open I want it to display a date 7 days ahead of todays date.
New to .asp but wanted to try something like "today()+7" but wasn't working

Can anyone help?
Thanks
<asp:TextBox ID="TextBox1" runat="server"  Width="120px"></asp:TextBox>

Open in new window

ShockUKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David RobitailleAnalyst ProgrammerCommented:
try this

<asp:TextBox ID="TextBox1" runat="server"  Width="120px"
             text='<%# Now().AddDays(7).tostring() %>'
></asp:TextBox>
 

Open in new window

0
ShockUKAuthor Commented:
When I input the above I get the following error

Error          The name 'Now' does not exist in the current context      C:\test\AccNum.aspx      
0
David RobitailleAnalyst ProgrammerCommented:
and this?
<asp:TextBox ID="TextBox1" runat="server"  Width="120px"
             text='<%# System.DateTime.Now().AddDays(7).tostring() %>'
></asp:TextBox>

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

David RobitailleAnalyst ProgrammerCommented:
did that answer your question?
0
ShockUKAuthor Commented:
Now I get this error message

Error      Non-invocable member 'System.DateTime.Now' cannot be used like a method.      
0
David RobitailleAnalyst ProgrammerCommented:
well, I really sorry it`s my fault
remove the () after the "Now"
System.DateTime.Now.AddDays(7).tostring()
that time, it Will work
http://bytes.com/forum/thread582980.html 

<asp:TextBox ID="TextBox1" runat="server"  Width="120px"
             text='<%# System.DateTime.Now.AddDays(7).tostring() %>'
></asp:TextBox>

Open in new window

0
ShockUKAuthor Commented:
lol
Now it doesn't look like the .tostring() part
Is there anything I need to do in the scripting page aswell to get this working or just the .aspx page?
0
ShockUKAuthor Commented:
Got past it with the below but now the box is just blank...
<asp:TextBox ID="TextBox1" runat="server"  Width="120px"
             text='<%# System.DateTime.Now.ToShortTimeString() %>'
></asp:TextBox>

Open in new window

0
David RobitailleAnalyst ProgrammerCommented:
ok, ok , ok
replace your textbox with this:

<asp:TextBox ID="TextBox1" runat="server" Width="120px" />
and put this ind code bhind.
This time, I tested it, i know should did id before, my appologies.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
If Not Page.IsPostBack Then 
TextBox1.Text = System.DateTime.Now.AddDays(7).ToShortDateString() 
End If 
End Sub
 
 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShockUKAuthor Commented:
Thanks mate,
Wish I could give you more than 500 points for this one
Bet it was one of those thread you wish you never picked up
0
David RobitailleAnalyst ProgrammerCommented:
I m gald i could help! If it was a long thread , it was only because I dident tested it. It was a really simple problem to me and that fact it was so simple make me cut the corner round and dont test it. 500 points is more than enough for that kind of question.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.