Avatar of arthurh88
arthurh88
 asked on

ASP.NET 4.5, VS2013: Get Input Type = Email in VB code behind

I simply want a way in my code behind (i'm using visual basic) to grab the value of this field:

  <input id="email" type="email" placeholder="Your email adress" runat="server">

But I dont know how?

Response.Write(email.Value)  does not work.


VS 2013 on .NET 4.5 and IIS 7 .

Any help?
CSSASP.NET.NET Programming

Avatar of undefined
Last Comment
arthurh88

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chinmay Patel

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
arthurh88

ASKER
id rather not use an asp.net text box.  i want to do it with an html input as I mentioned.  can it be done?
Chinmay Patel

Yes.

<input id="email" runat="server" type="Email" Placeholder="Mail Address"/>

Open in new window


and code behind will be
Response.Write(this.email.Value);

Open in new window

arthurh88

ASKER
says "email is not a member"   that is essentially what i tried.  i dont think its recognizing type=email, which is valid HTML5.  It will only work if type is text
Your help has saved me hundreds of hours of internet surfing.
fblack61
Chinmay Patel

I have a working example of this code it is working just fine. Can you post your pages? Also are you getting any other error?
arthurh88

ASKER
i can't post my page because it wont compile.  but the aspx code is this:
  <input id="name" type="text" placeholder="Your name" runat="server">
  <input id="email" type="email" placeholder="Your email adress" runat="server">
           
That page is fine, no errors.  the error is on the codebind with this line:

Public Class _004contact
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Write(name.Value)
        Response.Write(Me.email.Value)  ' ERROR IS HERE
    End Sub

End Class

The error says:
"Error      174      'email' is not a member of 'ther2._004contact'.
Chinmay Patel

ASPX code can't be just these two lines. It generally has page level directives, valid HTML and BODY tags then Form tags and within the form tag you will put in your controls. Or have you put codebehind on the same page?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
arthurh88

ASKER
i didn't post the entire aspx page, that wouldn't be relevant.  the aspx code I quoted is inside

<form id="form1" runat="server">

the head line says:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="004contact.aspx.vb" Inherits="ther2._004contact" %>
arthurh88

ASKER
there are no errors in the aspx page.  it is fine. the moment i take out the VB line of code it works great.
arthurh88

ASKER
Response.Write(name.Value)  = WORKS FINE
        Response.Write(email.Value)   = DOES NOT WORK
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Chinmay Patel

Try

  <input id="name" type="text" placeholder="Your name" runat="server"/>
  <input id="email" type="email" placeholder="Your email adress" runat="server"/>

Open in new window

arthurh88

ASKER
that doesn't work.  I have simplified everything:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
   <input id="name" type="text" placeholder="Your name" runat="server"/>
  <input id="email" type="email" placeholder="Your email adress" runat="server"/>
    
    
    </form>
</body>
</html>

Open in new window


and

Partial Class test
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        Response.Write(name.Value)
        Response.Write(email.Value)
    End Sub
End Class

Open in new window

arthurh88

ASKER
i figured out how to get my stylesheets and scripts to work on an <ASP> textbox control, so I found a way around it.  thanks for trying to help me :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
arthurh88

ASKER
this is pretty much what i ended up doing