?
Solved

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

Posted on 2013-12-22
14
Medium Priority
?
741 Views
Last Modified: 2013-12-23
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?
0
Comment
Question by:arthurh88
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 5
14 Comments
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 2000 total points
ID: 39735519
Where have you put this input control? Also why wouldn't you try ASP.net TextBox

<asp:TextBox id="email"  type="email" placeholder="Your email adress" runat="server" />

Open in new window


and in the code behind

Response.Write(this.email.Text);

Open in new window

0
 

Author Comment

by:arthurh88
ID: 39735529
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?
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39735557
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

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:arthurh88
ID: 39735575
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
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39735582
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?
0
 

Author Comment

by:arthurh88
ID: 39735602
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'.
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39735623
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?
0
 

Author Comment

by:arthurh88
ID: 39735636
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" %>
0
 

Author Comment

by:arthurh88
ID: 39735637
there are no errors in the aspx page.  it is fine. the moment i take out the VB line of code it works great.
0
 

Author Comment

by:arthurh88
ID: 39735638
Response.Write(name.Value)  = WORKS FINE
        Response.Write(email.Value)   = DOES NOT WORK
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 39735641
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

0
 

Author Comment

by:arthurh88
ID: 39735760
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

0
 

Author Comment

by:arthurh88
ID: 39735774
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 :)
0
 

Author Closing Comment

by:arthurh88
ID: 39735775
this is pretty much what i ended up doing
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question