PDA

Click to See Complete Forum and Search --> : A simple problem. Please help


Latin4567
Mar 25th, 2005, 09:32 PM
I am making a Contact page for a website using ASP.NET. In my aspx file there are a few textboxes. When I try to refer to these textboxes in script by their id's, it says that they are not declared. What am I doing wrong and how can I get this script to work?

dim Mname as string
dim Mphone as string
dim Memail as string
dim Mmessage as string

Public Sub Post

'There are textboxes on the form with the id's Name, Email, Phone and Message
'Here I need to Say that Mname = Name.text... excetera. But it doesnt work

Nname = Name.text


' Build a MailMessage
Dim mailMessage As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
mailMessage.From = "mbrefka@brefka.com"
mailMessage.To = "mbrefka@msn.com"
mailMessage.Subject = "Contact Form Results"
mailMessage.BodyFormat = System.Web.Mail.MailFormat.Html
mailmessage.Body = Mmessage

' TODO: Set the mailMessage.Body property

System.Web.Mail.SmtpMail.SmtpServer = "localhost"
System.Web.Mail.SmtpMail.Send(mailMessage)



end sub

mendhak
Mar 25th, 2005, 11:06 PM
Name might be a reserved keyword, so either change its ID in your HTML to something like username. Or, try placing [square brackets] around Name.

Latin4567
Mar 25th, 2005, 11:23 PM
Thanks for you help....

I tried what you said but it still says that name is not declared even though its an id in the html of the page :(

I tried using brackets and changing name to somthing else but it still wouldnt work

how do i get it to declare right?

Latin4567
Mar 26th, 2005, 11:12 AM
I kinda need help as soon as possible so could someone please respond :blush:

thx

mendhak
Mar 26th, 2005, 11:17 AM
This may sound like a strange solution, but try this:

Change the id of the element to "whatever".
Switch to designer view, save the document.
Build your project.
Go to the codebehind, and see if it shows up in intellisense.

mendhak
Mar 26th, 2005, 11:18 AM
If that don't work, delete the item and place it on the form again.

Latin4567
Mar 26th, 2005, 11:38 AM
I am using the ASP.NET webmatrix so there isnt any intellisense... but I tried what you said. It turns out that none of my id's work... no matter what I call them

mendhak
Mar 26th, 2005, 11:43 PM
Post all your ASPX code, highlight the relevant part.
Post the codebehind too, highlight the relevant part.