I am new to asp. I am using Visual Studio 2015 Community. I created a new Website over "File>New>Website>Website for AspWebForms "
Now my problem is I am writing now in CodeBehind, in my About.aspx.cs. If I try to get text from a asp Textbox over tb_bezeichnung.Text
it says it's not in context.
So after long search I figured out that i need a Designer.cs, I cant recreate it or have any options to Convert to WebForm.
<%@ Page Title="About" Language="C#" MasterPageFile="~/MasterPage.Master"
AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" %>
tb_bezeichnung is a Asp Textbox.
Project Explorer contents:
If I understand correctly, you want to take the value of your textbox, after let's say a button click for an example? Just create a Button and OnClick event and let's say add an Label in the design view, in the OnClick Method write:
in aspx file add:
<asp:Button ID="Button1" runat="server" Text="Click me !" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
Code behind:
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = TextBox1.Text;
}
Sounds like you've started with a "Web Site" instead of a "Web Application". A Web Site type uses older technology and is more difficult to maintain, I recommend starting over with a Web Application, which creates the designer files automatically. See Here..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.