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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user input form

Status
Not open for further replies.

zoidberg84

Programmer
Feb 21, 2006
9
GB
hello, i am trying to create a user input form that links to a database, everything is working fine apart from one problem... There is a field called "DateJoined" and i want the page to load with the current system date already in the dateJoinedTextBox!

I am writing in ASP.net 2.0 using Access as my DBMS!!

so far i have worked out aq way to get just the date using a javascript function:

Code:
<script type="text/javascript">
var currentTime = new Date()
var day = currentTime.getDate()
var month = currentTime.getMonth() + 1
var year = currentTime.getFullYear()
document.write(day + "/" + month + "/" + year)
</script>

but i cant get it into my text box in anyway cos it won't allow code between the <asp:textbox> tags and i am using templateFileds but am not sure how to do it!?

code for DateJoined TemplateField:

Code:
<asp:TemplateField HeaderText="Date Joined">
            <InsertItemTemplate>
                <asp:TextBox ID="dateJoinedTextBox" runat="server" Text='<%# Bind("DateJoined") %>'></asp:TextBox><br />
            </InsertItemTemplate>
        </asp:TemplateField>

any help would be great!
 
You don't need to use JavaScript (and probably shouldn't anyway for accessibility purposes). Simply use the System.DateTime.Now property and set it to the Text property of your TextBox.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top