求救呀!asp.net button_clik()没有反应搞了一天没找到原因,。
@信心 2013-05-09 11:16:35 asp.net button1_clik()没有反应搞了一天没找到原因。
源码如下:
<table class="style1" border ="1px">
<tr>
<td style="width: 120px; height: 33px;"> </td>
<td id= a1 style=" text-align: justify; height: 33px;">
<strong style="font-size: medium" > 渠道代理人需求提交</strong></td>
</tr>
<tr>
<td " style="width: 120px; text-align: right; font-size: small;"> 标题:</td>
<td >
<asp:TextBox id="Q_title" runat="server" Height="22px"
Width="384px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style7" style="width: 120px; text-align: right; font-size: small;"> 需求的类别:</td>
<td class="style10">
<asp:DropDownList id="Q_type" runat="server" Height="26px" Width="200px"></asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 120px; text-align: right; font-size: small;"> 需求内容:</td>
<td >
<asp:TextBox id="Q_desc" runat="server" Height="127px"
Width="384px"></asp:TextBox>
<tr>
<td style="width: 120px; text-align: right; font-size: small;"> 提交用户:</td>
<td style="width: 120px; text-align: right; font-size: small;" ><% =Session["user"]%></td>
</tr>
<tr>
<td style="width: 120px; text-align: right; font-size: small;"> 提交时间:</td>
<td style="width: 120px; text-align: right; font-size: small;"><% = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") %></td>
</tr>
<tr>
<td style="width: 120px; text-align: right; font-size: small;"> 选择服务专员:</td>
<td ><asp:DropDownList id="serviceNo" runat="server" Height="26px" Width="200px"></asp:DropDownList> </td>
</tr>
<tr>
<td style="width: 120px; font-size: small;"> </td>
<td >
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</td></tr>
</table>
</div>
</form>
</body>
</html>
code:
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class gyQuestion : System.Web.UI.Page
{
ST_DataBase ST_database = new ST_DataBase();
BaseOperate boperate = new BaseOperate();
OperateAndValidate opAndvalidate = new OperateAndValidate();
public string id;
private void InitializeComponent()
{
//this.Button2.Click += new System.EventHandler(this.Button2_Click);
//this.Load += new System.EventHandler(this.Page_Load);
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session["user"] == null)
{
//Response.Write("essss!!!!");
Response.Write("<script>alert(\"您还没有登录,不能进行接下来的操作,请登录后断续!\");</script>");
Response.Redirect("userlogin.aspx");
}// 在此处放置用户代码以初始化页面
if (!Page.IsPostBack)
{
DataTable ST_dt = new DataTable();
string strsql = "select * from guestion_type ";
ST_dt = ST_database.ReadTable(strsql);
Q_type.DataSource = ST_dt;
Q_type.DataTextField = "type_desc";
Q_type.DataValueField = "id";
Q_type.DataBind();
//Button2.Enabled = true;
// strsql = "select * from staff_info ";
// ST_dt = ST_database.ReadTable(strsql);
// serviceNo.DataSource = ST_dt;
// serviceNo.DataTextField = "emp_name";
// serviceNo.DataValueField = "empno";
//serviceNo.DataBind();
}
}
protected void Button2_Click(object sender, EventArgs e)
{
try
{
string connetstrl = boperate.DatabaseConnetString;
SqlConnection con = new SqlConnection(connetstrl);
con.Open();
SqlCommand com = con.CreateCommand();
com.CommandText = "insert into question_info (q_title,Q_type,Q_desc,sub_date,accept_user,Q_state,region_code,deptno) values (@q_title,@Q_type,@Q_desc,@sub_date,@accept_user,@Q_state,@region_code,@deptno)";
Response.Write("<script>alert('" + com.CommandText + "')</script>");
com.Parameters.Add("@q_title", SqlDbType.VarChar, 150);
com.Parameters.Add("@Q_type", SqlDbType.VarChar, 50);
com.Parameters.Add("@Q_desc", SqlDbType.VarChar, 50);
com.Parameters.Add("@sub_date", SqlDbType.DateTime);
com.Parameters.Add("@accept_user", SqlDbType.VarChar, 50);
com.Parameters.Add("@Q_state", SqlDbType.VarChar, 50);
com.Parameters.Add("@region_code", SqlDbType.VarChar, 20);
com.Parameters.Add("@deptno1", SqlDbType.VarChar, 20);
//===================values ===============
com.Parameters["@q_title1"].Value = Q_title.Text;
com.Parameters["@Q_type"].Value = Q_type.SelectedValue;
com.Parameters["@Q_desc"].Value = Q_desc.Text; ;
com.Parameters["@sub_date"].Value = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
com.Parameters["@accept_user"].Value = serviceNo.SelectedValue;
com.Parameters["@Q_state"].Value = "待回复";
com.Parameters["@region_code"].Value = "18";
com.Parameters["@deptno"].Value = "18001";
Response.Write("<script>alert('case!')</script>");
com.ExecuteNonQuery();
//Label1.Text = "提交的需求已存盘!";
//Response.Write("<script>alert('提交的需求已存盘!')</script>");
// infoclear();
con.Close();
}
catch (Exception er)
{
throw er;
// Label1.Text = "提交需求存盘出错!";
//
}