“User_Login”不包含“TextBox1”的定义,并且找不到可接受类型为“User_Login”的第一个参数的扩展方法“TextBox1”

qq_24306851 2015-12-19 07:29:11
...全文
486 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
快乐起航2020 2015-12-24
  • 打赏
  • 举报
回复
继承页面错误了,有可能
充满荆棘的路 2015-12-24
  • 打赏
  • 举报
回复
下面那个Db上面的红线,暴露了你Copy的不完整!!!
dpcStudent 2015-12-23
  • 打赏
  • 举报
回复
你复制别人的代码吧!把两个文本框也复制过来啊
正怒月神 版主 2015-12-23
  • 打赏
  • 举报
回复
前台没有叫做 TextBox1的控件
目生鱼 2015-12-23
  • 打赏
  • 举报
回复
你可以把aspx里面的代码删除了重写写一遍
EdsionWang 2015-12-22
  • 打赏
  • 举报
回复
从哪复制的代码呢?把人家的教程读仔细了,别只顾着复制粘贴代码。就算你拖两个TextBox到aspx文件上,你下面还有个DB报错。
马球球 2015-12-22
  • 打赏
  • 举报
回复
看你前台设计页有没有这俩id的控件,要有还报错,那你就重新再打一遍,点一遍。有时候刷新慢
秋的红果实 2015-12-21
  • 打赏
  • 举报
回复
找到User_Login.aspx页面,切换到 设计 视图,从工具箱拖2个TextBox控件到页面上
秋的红果实 2015-12-21
  • 打赏
  • 举报
回复
你的页面上有ID是TextBox1和TextBox2的控件吗?
快乐起航2020 2015-12-21
  • 打赏
  • 举报
回复
标签有不完整的地方导致错误
abz7676 2015-12-19
  • 打赏
  • 举报
回复
检查一下你的这个前台页面是否有TextBox1,TextBox2这两个控件,还有检查一下TextBox1和TextBox2的大小写是不是一致。
很简单!刚学的!有登录和注册using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsFormsApplication2 { public partial class Form1 : Form { SqlConnection conn = null; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try{ SqlCommand com = conn.CreateCommand(); string users = textBox1.Text; string password = textBox2.Text; com.CommandText = "select * from T_login where LOGIN_user='"+users+"'"; SqlDataReader reader = com.ExecuteReader(); if (reader.Read()) { //用户名正确! string dbpassword = reader.GetString(reader.GetOrdinal("LOGIN_password")); if (password == dbpassword) { MessageBox.Show("登陆成功!"); } else { MessageBox.Show("密码错误!"); } } else { MessageBox.Show("用户名错误!"); } reader.Close(); } catch(Exception ex) { MessageBox.Show(ex.Message); } } private void Form1_Load(object sender, EventArgs e) { string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True"; try { conn = new SqlConnection(connString); conn.Open(); MessageBox.Show("成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { conn.Dispose(); } private void button3_Click(object sender, EventArgs e) { try { SqlCommand com = conn.CreateCommand(); string users = textBox1.Text; string password = textBox2.Text; com.CommandText = "select * from T_login"; SqlDataReader reader = com.ExecuteReader(); label3.Text = "id,用户名,密码\n"; while (reader.Read()) { label3.Text = label3.Text +"\n"+ string.Format("{0},{1},{2}", reader[0], reader[1], reader[2]); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void button2_Click(object sender, EventArgs e) { try { SqlCommand com = conn.CreateCommand(); string users = textBox1.Text; string password = textBox2.Text; com.CommandText = "select * from T_login where LOGIN_user='" + users + "'"; SqlDataReader reader = com.ExecuteReader(); if (reader.Read()) { //用户名存在! MessageBox.Show("用户名已经存在"); reader.Close(); } else { reader.Close(); //可以注册 com.CommandText = "INSERT INTO T_login (LOGIN_user, LOGIN_password) VALUES ('"+users+"', '"+password+"')"; com.ExecuteNonQuery(); MessageBox.Show("注册成功!"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
Author: aspnet100@yahoo.com LoginControl Revision History:V.1.2.2.1 - 09-28-2003 *New: 1.Login (and Password) label can be in a separate row from the input text box. 2.Login Confirmation is available by option. 3.Add ValidatorStyle for LoginID and Password validators. 4.Can call a javascript function when Login control loads. 5.Allow non-named colors (e.g. #eeffdd) in BackColor and BorderColor. *Change: 1.DLL name changed to Mars.Controls.LoginControl.dll. 2.Change default label font to Verdana. 3.Login and Register Buttons aligned to the left. 4.No more built on .NET Framework V.1.0.3705. 5.New Taget at .NET Framework V.1.1.4322. V.1.1.0.0 - 04-27-2003 *New: Added a "Remember Password" check box. *Change: Improved user experience: the control will now display instantly when it s dropped on the Web form, no need to first select the Button Type in the Property window. *Change: DLL name changed to JoeWoods.LoginControl.dll from JoeWoods.ServerControls.dll. V.1.0.0.0 - 04-21-2003 Initial Version Target: .NET Framework V.1.1.4322 **V.1.2.2.1 Note** The following Description and Installation have been edited specifically for LoginControl - V.1.2.2.1, for general information, the Note in the previous release still applies. 1. There is one new DLL in the zipped file: Mars.ConfirmedButtons.dll, please copy it into the /bin folder. This DLL provides the optional login confirmation set by LoginConfirmedRequired attribute. 2. Supports client JS function when control loads, which is very useful if you need to call client side function e.g. preloading images for dynamic visible affect. 3. In the JS function, do not use alert to pop up a message. Otherwise, it will hide the client side validation. 4. If you change LoginConfirmationRequired in the Desginer, you might need to (save and) reopen the page to have it take effect. 5. The enclosed example shows you some new functionality in this new version. There is more, please explore youself and have fun. 6. To run the new sample page: enter /localhost//admin/loginControlTest1221.aspx, if you have followed the installatiion procedure below. **V.1.1.0.0 Note** The following Description and Installation have been edited for LoginControl - V.1.1.0.0. Description: LoginControl is a custom server control which provides the Form user authentication graphic interface for a secure Web site. It is completely design time configurable, contains the following child controls: 1. LoginID Label, 2. LoginID Textbox, 3. LoginIDRequiredFieldValidator, 4. Password Label, 5 Password Textbox, 6. PasswordRequiredFieldValidator, 7. Login Textbutton, 8. Login Linkbutton, 9. Register Textbutton, 10. Register Linkbutton. 11. "Remember Password" Label, 12. "Remember Password" CheckBox. and exposes the following properties to programmatically access the user input: 1. LoginID (string), 2. Password (string), 3. IsRememberPassword (bool). Login button is mandatory, Register button and Remeber checkbox are optional. All child controls can be visually designed in the IDE such as VS.NET. This includes label captions, validator messages, the size and maxLength of textboxes, style of the label, textbox, text button, link buttons, font name, colors, etc. There are two types of action buttons to choose for Login and Register: Text button and Link button. The control users (or the Page developers) must provide an event handler for Logon event so the form s Postback can authenticate the user input credential. An optional Register button can be displayed for redirecting a new user to a Registration form. The optional "Remember Password" can be used to set permanent authentication cookies if users choose to do so. The Registration form must be an ASPX page (even it is an HTML form), and its URL should be specified using relative path if it is in a different folder(e.g. ../reg/Registration.aspx ). One nice feature of the control is it automatically sets initial focus on the LoginID textbox when the page loads. It is assumed that the control is used in the first form of the page. This is true as long as the Framework does not support more than one form as it currently. The control provides three accessors: LoginID, Password, and IsRememberPassword of user input, which you would need to use for programmatic authentication. NOTE: The control has been built and tested in .NET Framework V1.0.3705. The zipped file includes one DLL of the control itself, and several sample ASPX files, in two folders, to demostrate how the control being used. Please follow the instructions below to install the control and see how the sample works. Installation: 1. Unzip the loginControl.zip file and extract it to a temp folder. 2. Create a virtual directory or use an existing one, copy both Mars.Controls.LoginControl.dll and Mars.ConfirmedButtons.dll to its /bin folder. 3. Copy the other two folders (/admin and /reg) under this virtual directory. 4. In the IE browser, enter /localhost//admin/loginControlTest11.aspx to see the text button version of the working Login control. 5. Enter /localhost//admin/loginControlTestL11.aspx to see the link button version of the slightly different design. 6. You can click the Register button to view a Registration form. 7. To use LoginControl in your own project, do the following: 8. In your ASP.NET Web project, right-click on References folder, select "Add Reference...", "Browse..." to add JoeWoods.LoginControl.dll to the project, this will copy the control dll in the project s /bin folder. 9. Next, bring up your Toolbox pane by clicking the View menu, select "Toolbox", select "Web Forms" tab. Right-click anywhere in the pane and select "Customize Toolbox...", click ".Net Framework" tab, browse and locate JoeWoods.LoginControl.dll as you did in step 1. This will create the LoginControl icon in the Toolbox that you can drag and drop in the Designer. (Sorry that I could not get a designated icon next to the control. I tried to embed it without shipping the separated bitmap file but no luck. Show me if you have a sample project to do so). 10. Now you are ready to use the control in your Web form. Just drag the LoginControl icon in the ToolBox pane and drop it to the Web form. The control should appear in the form with all its child controls. By manipulating the Property window, you can design the control to fit your need. If you do not want to show the optional Register button or Remeber check box, simply change the RegisterButtonText or RememberPasswordText to empty string. 11. Do not forget to provide an event handler for the Logon so the Postback can handle the user authentication properly. 12. All rights reserved to the control author - aspnet100@yahoo.com. By using the control you accept the disclaimer below: 13. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

62,039

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧