Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 7th, 2006, 01:23 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default textbox initialization in Formview

I've create an input form using Formview's InsertItemTemplate control. There's one field I want to initialize it to today's date:

    Protected Sub frmMain_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim strToday As String = DateTime.Now.ToString("d")
        If (frmMain.CurrentMode = FormViewMode.Insert) Then
            (TextBox)frmMain.FindControl("txtPubDate").text = strToday
        End If
    End Sub

But I keep getting syntax error at the assignment statement. I've played with the placements of the parentheis but it still doesn't work.

Have spent a lot of time on "simple" thing like this. Any insight appreciated. Thanks.

Reply With Quote
  #2 (permalink)  
Old November 7th, 2006, 05:43 PM
Imar's Avatar
Wrox Author
Points: 71,692, Level: 100
Points: 71,692, Level: 100 Points: 71,692, Level: 100 Points: 71,692, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,019
Thanks: 79
Thanked 1,580 Times in 1,557 Posts
Default

The syntax you're using is for C#, not VB. Assuming that frmMain.FindControl("txtPubDate") results in a valid textBox, try this:

CType(frmMain.FindControl("txtPubDate"), TextBox).Text = strToday


Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #3 (permalink)  
Old November 17th, 2006, 07:30 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using the same code.. in c#... The stange thing is that the code executes ok... as far as assigning the date by the DetailsView does not reflect the new value.. What am I doing wrong?

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Highlighting a textbox in a formview amatytfc ASP.NET 2.0 Basics 0 October 12th, 2007 03:13 PM
Reference a textbox in a formview amatytfc ASP.NET 2.0 Basics 12 September 26th, 2007 11:36 AM
Populate a Textbox in a Formview timeware ASP.NET 2.0 Basics 0 September 29th, 2006 10:08 AM
initialization vin_0x1 Classic ASP Professional 3 April 16th, 2006 06:40 AM



All times are GMT -4. The time now is 09:34 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.