![](/img/trans.png)
[英]Javascript not reading value from hidden textBox - JQuery C#
[英]Error reading TextBox value in C#
我在制作从TextBox读取文本的程序时遇到了一些问题。 我正在从两个TextBoxes中读取两个值,但似乎实际上没有读取任何内容。 最终发生的事情是,我在TextBoxes中输入值,然后按按钮将值输入到程序中。 我设置它来打印出我的TextBoxes中的值,但是当它打印时,看起来好像没有从TextBoxes中读取任何内容。
这是我的窗口代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Giveaway_Program
{
public partial class giveawayProgram : Form
{
public GiveawayEntry[] entries = {};
public giveawayProgram()
{
InitializeComponent();
}
private void Giveaway_Load(object sender, EventArgs e)
{
}
private void panel_Paint(object sender, PaintEventArgs e)
{
}
private void emailText_TextChanged(object sender, EventArgs e)
{
}
private void nameText_TextChanged(object sender, EventArgs e)
{
}
private void numberOfTimes_ValueChanged(object sender, EventArgs e)
{
}
private void addToList_Click(object sender, EventArgs e)
{
addEntry(new GiveawayEntry(emailText.Text, nameText.Text));
}
private void generateWinner_Click(object sender, EventArgs e)
{
}
private void addEntry(GiveawayEntry newEntry)
{
GiveawayEntry[] newEntries = new GiveawayEntry[entries.Length + 1];
Array.Copy(entries, newEntries, entries.Length);
entries = newEntries;
for (int i = 0; i < entries.Length; i++)
{
Console.WriteLine("Name: " + entries[i].Name + ", Email: " + entries[i].Email);
}
}
}
}
这是值进入的结构:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Giveaway_Program
{
public struct GiveawayEntry
{
string email, name;
public GiveawayEntry(string _email, string _name)
{
email = _email;
name = _name;
}
public string Email
{
get
{
return email;
}
}
public string Name
{
get
{
return name;
}
}
}
}
这是程序的控制台输出:
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\Users\Overlord Nate\Google Drive\Projects\Giveaway Program\Giveaway Program\bin\Debug\Giveaway Program.vshost.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0xd4c has exited with code 0 (0x0).
The thread 0x28e8 has exited with code 0 (0x0).
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\Users\Overlord Nate\Google Drive\Projects\Giveaway Program\Giveaway Program\bin\Debug\Giveaway Program.exe'. Symbols loaded.
'Giveaway Program.vshost.exe' (CLR v4.0.30319: Giveaway Program.vshost.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Name: , Email:
The thread 0x2ec0 has exited with code 0 (0x0).
The thread 0x1630 has exited with code 0 (0x0).
The program '[6500] Giveaway Program.vshost.exe' has exited with code 0 (0x0).
“名称:,电子邮件:”是我的值应该存在的位置。
在此先感谢您的帮助,如果您需要更多信息,请简单地说,我会提供。
private void addEntry(GiveawayEntry newEntry)
{
GiveawayEntry[] newEntries = new GiveawayEntry[entries.Length + 1];
Array.Copy(entries, newEntries, entries.Length);
entries = newEntries;
for (int i = 0; i < entries.Length; i++)
{
Console.WriteLine("Name: " + entries[i].Name + ", Email: " + entries[i].Email);
}
}
newEntry
添加到数组 List<GiveawayEntry>
,将会容易得多。 struct
。 除非有令人信服的理由将其用作struct
否则仅使用class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.