• 0

ASP.Net Web Form


Question

Recommended Posts

  • 0

I know how to add more fields to the actual visual form but I am having problems because I dont know how to alter the asp.net code so those addtional fields send their information as well:

<% @Import Namespace="System.Web.Mail" %>

<script language="vb" runat="server">

Sub contactUS_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

objMM.To = "myemail@email.com"

objMM.From = email.Text

'If you want to CC this email to someone else

'objMM.Cc = "myemail@email.com"

'email format. Can be Text or Html

objMM.BodyFormat = MailFormat.Html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Contact Us"

'Set the body

objMM.Body = message.text

'Smtp Server

SmtpMail.SmtpServer = "xx.xx.net"

'Send the message

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

</script>

  • 0

add & symbol and enter texts or texts from texbox

e.g objMM.Body=message.Text & textbox.text

Or

objMM.Body=message.text & "something that you want to add" & textbox.text

if you want to add your text in different lines add vbcrlf

objMM.Body=message.text & "something that you want to add" & vbcrlf & textbox.text

  • 0

you mean the value of dropdown? because you cannot add the dropdown. if you want the value is dropdown.selectedvalue for the value or dropdown.selecteditem.tostring the text that shows in the dropdown remember that the selectedvalue property has to be assigned by you which filed to be used in the properties of the dropdown

  • 0

I keep getting errors when i use the following

objMM.Body=message.Text & textbox.text

Error Message:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30469: Reference to a non-shared member requires an object reference.

Source Error:

Line 23:

Line 24: 'Set the body

Line 25: objMM.Body=message.Text & textbox.text

Line 26: 'Smtp Server

Line 27: SmtpMail.SmtpServer = "xx.xxx.net"

  • 0

<% @Import Namespace="System.Web.Mail" %>

<script language="vb" runat="server">

Sub contactUS_Click(sender as Object, e as EventArgs)

'Create an instance of the MailMessage class

Dim objMM as New MailMessage()

objMM.To = "acousticalexakis@msn.com"

objMM.From = email.Text

'If you want to CC this email to someone else

'objMM.Cc = "xx@xx.com"

'email format. Can be Text or Html

objMM.BodyFormat = MailFormat.Html

'Set the priority - options are High, Low, and Normal

objMM.Priority = MailPriority.Normal

'Set the subject

objMM.Subject = "Contact Us"

'Set the body

objMM.Body = name.text & vbcrlf & message.text & vbcrlf & phone.text

'Smtp Server

SmtpMail.SmtpServer = "xx.xxx.net"

'Send the message

SmtpMail.Send(objMM)

panelSendEmail.Visible = false

panelMailSent.Visible = true

End Sub

  • 0
  MyServerGuy said:
What I usually use is:

Environment.NewLine()

=D

586780184[/snapback]

Now that is clever. I have never see that one before.

I was excited when I was first introduced to string.empty. Now I like environment.newline. :woot:

  • 0

LOL @ chorpeac!!! It's more scalable since it changes the "new line character" depending on what the current operating environment is. And at first thought you wouldn't think that'd be a big deal, but always try to make your apps as scalable and portable as humanly possible (and I'm just stating that for anybody else that reads this as I know that you "know your stuff" because I've been here for quite some time as well lol).

You could use it like this:

MailMessage.Body = txtMyMessage.Text &amp; Environment.NewLine() &amp; Now().ToString()

(or similar)

Or:

dim NL as object = Environment.NewLine()
MailMessage.Body = txtMyMessage.Text &amp; NL &amp; Now().ToString()

which is my favorite since very seldom are concatenated strings plain and simple like that... so it produces alot less typing which in turn makes things easier to read. It also makes it simpler to change between formats. For example, in the case of using the mailmessage object, if you are using text and decide to switch to HTML then all you have to do is change that variable to:

dim NL as string = "&lt;br /&gt;"

At least I think it's cleaner all the way around :)

  • 0

Okay, my settings were set to HTML so I used the code to send it in HTML:

dim NL as string = "<br />"

objMM.Body = name.text & NL & Now().ToString()& phone.text & NL & Now().ToString() & "Message" & message.text

I still have two remaining problems and hopefully they are easy to solve.

1. When i receive the email from the submitted form each line now has a date that I dont want before the information, for example:

Kev

11/8/2005 10:01:15 AM555-555-5555

11/8/2005 10:01:15 AMMessagetest3

2. I added "Message" & message.text to show which field is which. Is this the best method for doing that? Is there a way to add any html formattin to this such as bold and a space to seperate the field name and the text in the sent email?

Thank you very much for all of your help. I truly appreciate it.

  • 0

Of course... wrap whatever you want in <b></b> or <strong></strong> tags...

Now() is a DateTime object which reflects the current system date and time when called. ToString() is a method that when called performs a cast/conversion of the object to a string format. Hence, when used via concatenation, it outputs the current date and time.

There are other methods for this object that can be used as well... ToLongDateString(), ToShortDateString(), so on and so forth (but you can't just make them up... you must use predefined methods, of course, unless you want to begin writing your own objects which I would say is well worth your time for getting a good understanding of how programming really works - IMHO tho, and only my opinion).

  • 0

Alright the form is up and working all thanks to you! :) There are still minor issues i want to solve if your able to help. When the form produces an error such as when someone doesnt enter their email address i am sent to an error page that includes "Server Error in '/' Application." Is there a way to not allow the form to be submitted if someone doesnt fill in the email field or just to have the form foward to an error page that i can create to let the user know they need to go back and fill in the email box?

  • 0

For just checking if the field is not blank you want to use RequiredFieldValidators. Like so, just make the appropriate changes...

&lt;asp:RequiredFieldValidator ID="rfvOne" runat="server" ControlToValidate="txtTextBoxNameToValidate" EnableClientScript="true" Display="Dynamic" ErrorMessage="This is where the error message goes.  PUT TEXT IN THIS FIELD, N00B!!!" /&gt;

However, if you want to check to make sure that the information entered follows a specific format, then you'll have to use the RegularExpressionValidator. Now, heed my notice, I will not help you with regular expressions. Supporting my own software keeps me busy enough with these things sometimes, so not to be rude but I will not support yours ;) I think you know where I'm getting at. But here's an example anyway. BTW, you can use Google to find any regular expression you may ever need. So I'm not saying don't use this, just dont ask me to write/modify regex's for you (regular expressions).

&lt;asp:RegularExpressionValidator ID="revIDName" runat="server" ControlToValidate="txtControlToValidate" EnableClientScript="true" Display="Dynamic" ValidationExpression="RegularExpressionToUse" ErrorMessage="Again, where the error message goes  =D" /&gt;

Then, in your submit routine, just make sure that you check to see if your page is valid...

Sub SendMail (ByVal Sender As Object, ByVal e As EventArgs)
    If NOT(Page.IsValid) Then Exit Sub
...
End Sub

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • This excellent 27-inch 1440p 240Hz QD-OLED gaming monitor is way under $500 by Sayan Sen If you are on the hunt for a great gaming monitor that is under $500, then AOC has a great option today that is worth considering. The model in question is the AOC Q27G4ZD which is a 27-inch 240 Hz display based on QD-OLED (Quantum Dot OLED) and it is at just $428 making it lowest ever priced (purchase link under the specs table below). The specialty of QD-OLED is that pairs the self-emissive OLED pixels with a layer of quantum dots, converting blue OLED light into pure red and green wavelengths more efficiently than traditional color filters. The result is brighter highlights, wider color gamut, and higher color volume without sacrificing OLED’s infinite contrast and instant response. Quantum dots are also said to reduce energy loss in color conversion, while boosting luminance and vibrancy. Thanks to the excellent color reproduction alongside the contrast, this QD-OLED monitor can be used for professional photo/video editing, animations, and such as well, plus working on spreadsheets and other office docs should be a breeze too. The technical specifications of the AOC Q27G4ZD are given below: Specification Details Diagonal Screen Size 26.5 " (67.3 cm) Panel Technology Quantum Dot OLED (QD-OLED) Maximum Refresh Rate 240 Hz (DP 1.4) 144 Hz (HDMI 2.0) Response Time (GtG) 0.03 ms (GtG) Brightness (Typ.) 450 cd/m² (10 % APL) Peak Brightness (HDR) 1000 cd/m² (3 % APL) Color Gamuts RGB 100% (CIE1931) / DCI-P3 99% (CIE1976) Color Accuracy Delta E < 2 Display Colors 1.07Billion HDR Certification VESA DisplayHDR™ True Black 400 Sync Technology Adaptive-Sync Contrast Ratio 1,500,000:1 (Typical) Color Depth 10-bit Connectivity 1 × DisplayPort 1.4 2 × HDMI 2.0 1 × 3.5 mm Audio Out 4x USB 3.2 Gen1 Ergonomics Height: 130 mm Tilt: –5 ° ~ 23 ° Swivel: –30 ° ~ 30 ° Pivot: –90 ° ~ 90 ° Bezel 3-sided frameless Special Features Flicker-Free, Low Blue Mode, Gaming Modes (FPS/Racing/RTS/Gamer1–3), Shadow Control, Game Color, Dial Point, Sniper Scope, Low Input Lag Get the AOC Q27G4ZD 27" QD-OLED at the link below: AOC Q27G4ZD 27" QD OLED Gaming Monitor, 3-Year Zero-Bright-Dot: $427.69 (Sold and Shipped by Amazon US) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • But even when it says local, it is not local, they all send info back. I bet if you unplug your computer from the net, they would not work Not saying that AI can't do useful stuff, just I don't want it pushed onto me all the flipping time
    • I know I will get shot down for this, but I prefer Windows 8, take the start screen away and use a third party start menu and Windows 8 was a pretty good OS for Microsoft. It was stable and ran very smoothly on my AMD bulldozer based computer, Windows 10 ran like a dog. When I changed to a Ryzen 7 17090 CPU, I tried to keep Windows 8 on it, but MS made that difficult with pop-ups all the time to get me to change to Windows 10 and the hacks to stop it, did not work that well. I have seen for a few years now the way Windows is going, and I don't like it and with Windows 11, what I saw was happening with Windows 10 have got worse with 11, certainly now with this AI rubbish. When I was looking at updating my PC a couple of years ago, I was looking at what CPUs were available, price and if it was going to make a lot of difference to what I use the machine for. To update my Pc to would have cost me £700 or more, that is just for the CPU, memory and board, maybe get a new case, the GPU is fine for what I use it for. I waited to see what AMD was bringing out and I thought I would look at what Apple was doing with their machines, and they launched the M2 machine at around the same time as AMD launched a new gen version of their Ryzen chip. A Mac mini m2 pro was £1,300, I had saved the money up over 12 months and yes the mini was over £600 more than the parts to update the PC, but it was a complete computer. I had the money, so I thought stick it, let's go for it. I don't regret it, what I do regret is not going for Mac years ago. Saying that Apple used Intel chips and I hate intel. I will have to update the PC at some point, but I will go for a R5 and not R7 and have less memory and a cheaper motherboard as the machine is only used for a few games these days.
    • Gemini CLI brings AI smarts to your Firebase terminal experience by Paul Hill Google has added its Gemini AI model directly into the command-line interface of Firebase Studio, its cloud-based IDE that uses AI to help with projects. The Gemini Command Line Interface (CLI) means that developers can expand past using AI for code, they can now also use AI for content generation and research without leaving the IDE. Gemini CLI comes with free usage tiers (60 model requests per minute, 1,000 requests per day with a Google login), it offers advanced AI features, and includes integrated Google Search for real-time content. Gemini CLI is also open source so it can be customized and accepts contributions. Accessing the Gemini CLI within Firebase Studio is straightforward, just press “Code view” in the top-right. From there, open up the terminal from the burger menu then select Terminal and New Terminal. Then in the terminal, type gemini and go through the setup, you can just press enter twice to get started. Out of the box, you’ll be able to get started with Gemini 2.5 Pro by just typing a query and pressing enter. There is also a non-interactive mode that’s useful for scripting and automation. To use it you use the –prompt or -p flags followed by your query wrapped in quotes, for example: gemini -p “What is the capital of France?” In this mode, Gemini CLI automatically closes after completing the request. During setup, there was the option to choose a theme. If you ever want to change it or look at other settings such as usage states, tool access, or checkpointing, you can edit them via .gemini/settings.json. You can also add API keys or choose different models in .env and you can using GEMINI.md to provide project-specific context, instructions, and coding styles in Gemini for a more tailored response. With Gemini CLI, you can have it explain code, refactor code, debug errors, and summarize information. It’s as simple as typing explain [file], refactor , debug “Error message”, or summarize “topic”. There are also built-in commands for managing the session such as /help for a command list, /chat to save and resume conversations, /tools to see available tools, and /restore to undo tool-made file edits. Firebase Studio, in true Google fashion, is a cloud-based IDE used in your web browser, making it excellent for weaker computers. To get started, you can head to the Firebase website. From there, tap Studio in the top-right.
  • Recent Achievements

    • Week One Done
      MIghty Haul earned a badge
      Week One Done
    • One Month Later
      MIghty Haul earned a badge
      One Month Later
    • Collaborator
      KD2004 earned a badge
      Collaborator
    • One Month Later
      ataho31016 earned a badge
      One Month Later
    • One Month Later
      Delahenty Machinery earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      592
    2. 2
      Michael Scrip
      200
    3. 3
      ATLien_0
      192
    4. 4
      +FloatingFatMan
      140
    5. 5
      Xenon
      127
  • Tell a friend

    Love Neowin? Tell a friend!