button click事件不提交的问题,恳请指点!!!!!

suchAfool 2005-10-20 06:46:14
button事件不提交的问题!!
无错误提示,代码片段:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace fiance
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.TextBox TextBox5;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!Page.IsPostBack)
{
DoDataBind();
}

}
private void DoDataBind()
{
SqlDataAdapter cmd=new System.Data.SqlClient.SqlDataAdapter("select * from ioType order by ioType_id",this.sqlConnection1);
SqlDataAdapter cmd1=new System.Data.SqlClient.SqlDataAdapter("select * from unit",this.sqlConnection1);
DataSet ds=new DataSet();
DataSet ds1=new DataSet();
cmd.Fill(ds,"ioType");
cmd1.Fill(ds1,"unit");

this.DropDownList1.DataSource=ds.Tables["ioType"].DefaultView;
this.DropDownList1.DataTextField="ioType_name";
this.DropDownList1.DataValueField="ioType_id";
this.DropDownList1.DataBind();

this.TextBox3.Text=" ";

this.DropDownList2.DataSource=ds1.Tables["unit"].DefaultView;
this.DropDownList2.DataTextField="unitName";
this.DropDownList2.DataValueField="unitId";
this.DropDownList2.DataBind();

string ScriptBlock="<script language='javascript'>function DoSelect() {";
ScriptBlock+="window.open('select.aspx','选择商品编号','width=317px,height=150px,status=no');";
ScriptBlock+="}</script>";
if (!Page.IsClientScriptBlockRegistered("clientScript"))
{
Page.RegisterClientScriptBlock("clientScript",ScriptBlock);
}
this.TextBox3.Attributes["onclick"]="javascript:DoSelect();";
}


#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = ((string)(configurationAppSettings.GetValue("ConnectionString", typeof(string))));
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

protected void Button1_Click(object sender, System.EventArgs e)
{
//Response.Redirect("wwwerw");
Response.Write("asdfasdfasdf");
//SqlCommand cmd=new SqlCommand("insert into fiance (com_number,com_unit,iotype_id,iocount,iprice,ich,ichc,jiecun,manager,opdate,opmemo) values ()",this.sqlConnection1);
}


}
}
...全文
176 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
suchAfool 2005-10-20
  • 打赏
  • 举报
回复
html:


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace fiance
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.TextBox TextBox4;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Web.UI.WebControls.TextBox TextBox3;
protected System.Web.UI.WebControls.DropDownList DropDownList2;
protected System.Web.UI.WebControls.TextBox TextBox5;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if (!Page.IsPostBack)
{
DoDataBind();
}

}
private void DoDataBind()
{
SqlDataAdapter cmd=new System.Data.SqlClient.SqlDataAdapter("select * from ioType order by ioType_id",this.sqlConnection1);
SqlDataAdapter cmd1=new System.Data.SqlClient.SqlDataAdapter("select * from unit",this.sqlConnection1);
DataSet ds=new DataSet();
DataSet ds1=new DataSet();
cmd.Fill(ds,"ioType");
cmd1.Fill(ds1,"unit");

this.DropDownList1.DataSource=ds.Tables["ioType"].DefaultView;
this.DropDownList1.DataTextField="ioType_name";
this.DropDownList1.DataValueField="ioType_id";
this.DropDownList1.DataBind();

this.TextBox3.Text=" ";

this.DropDownList2.DataSource=ds1.Tables["unit"].DefaultView;
this.DropDownList2.DataTextField="unitName";
this.DropDownList2.DataValueField="unitId";
this.DropDownList2.DataBind();

string ScriptBlock="<script language='javascript'>function DoSelect() {";
ScriptBlock+="window.open('select.aspx','选择商品编号','width=317px,height=150px,status=no');";
ScriptBlock+="}</script>";
if (!Page.IsClientScriptBlockRegistered("clientScript"))
{
Page.RegisterClientScriptBlock("clientScript",ScriptBlock);
}
this.TextBox3.Attributes["onclick"]="javascript:DoSelect();";
}


#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = ((string)(configurationAppSettings.GetValue("ConnectionString", typeof(string))));
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

protected void Button1_Click(object sender, System.EventArgs e)
{
//Response.Redirect("wwwerw");
Response.Write("asdfasdfasdf");
//SqlCommand cmd=new SqlCommand("insert into fiance (com_number,com_unit,iotype_id,iocount,iprice,ich,ichc,jiecun,manager,opdate,opmemo) values ()",this.sqlConnection1);
}


}
}
suchAfool 2005-10-20
  • 打赏
  • 举报
回复
试一下~~
suchAfool 2005-10-20
  • 打赏
  • 举报
回复
要重建才行吗?
solodonut 2005-10-20
  • 打赏
  • 举报
回复
把html代码发过来看一下
yhloveys 2005-10-20
  • 打赏
  • 举报
回复
我的界面是不是复制html代码过来的?
我也遇到过,我是重建页面才解决的(不能全总复制别的页面的代码)
suchAfool 2005-10-20
  • 打赏
  • 举报
回复
是在form里的,我也想不通了~~~
suchAfool 2005-10-20
  • 打赏
  • 举报
回复
刚才按你说的试了一下,还是不行啊```
solodonut 2005-10-20
  • 打赏
  • 举报
回复
这部分好像没有太大问题,是不是在HTML页面里没有把Button写道FORM里面?
njmaxiang 2005-10-20
  • 打赏
  • 举报
回复
看不出有什么问题,建议重新建一个页面试一下,我以前就是这样解决的
cw888 2005-10-20
  • 打赏
  • 举报
回复
在InitializeComponent()函数中加入

private void InitializeComponent()
{

this.Button1.Click += new System.EventHandler(this.Button1_Click);
}

62,046

社区成员

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

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

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

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