I am working on my first website (using twitter oAuth) through Visual Studio 2012 for the class. I feel idiotic about having to ask this question, because I am sure it is very simple.
I'm having trouble getting code to recognize any web elements on my .aspx page. I'm not sure if I need to change something in the settings or if I just missed something.
I added a text box through the toolbar to "index.aspx" and gave it id = 'txtUserName'. When I try to assign txtUserName.Text to a variable in page_load, I get an error in which "txtUserName" does not exist in the current context.
Hope someone can make me pat my head and that I missed a simple tag or something like that.
index.aspx:
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="index.aspx.cs" Inherits="TwitterTest.index" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>TwitterTest!!!</title> </head> <body> <form id="form1" runat="server"> <div> Welcome to TwitterTest </div> <asp:TextBox ID="txtUserName" runat="server" Text=""></asp:TextBox> </form> </body> </html>
index.aspx.cs:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Mvc; using TweetSharp; namespace TwitterTest { public partial class index : System.Web.UI.Page { static void Page_Load(object sender, EventArgs e) { string UserName = txtUserName.Text; } } }
source share