按钮单击不会调用功能

时间:2016-12-14 22:02:20

标签: c# asp.net

在aspx文件中,当我更改按钮的位置时它的工作正常但是当我把它放在当前的psitiion中时,click方法不会调用; 点击功能正确

  
    

button4(代码结束)

  
  <div class="ui  container">
    <div runat="server" id="mydiv" class="ui form">

    </div>
</div>
<button onclick="myFunction()">Click me</button>
<div class="ui modal">
    <i class="close icon"></i>
    <div class="header">
        Add request
    </div>
    <div class="image content">
        <div class="ui form">
            <label>user id</label>
            <input runat="server" id="usid" type="text" />
            <label>Details</label>
            <textarea id="details" runat="server" rows="2"></textarea>
            <label>Cost</label>
            <input id="cost" runat="server" type="text" />
            <label>dead time</label>
            <input id="date" runat="server" class="ui date" type="date" />
        </div>
    </div>

    <div class="actions">
         <asp:Button ID="Button4" class="ui positive right labeled icon button" runat="server" OnClick="Button4_Click" Text="Button" />

        <i class="checkmark icon"></i>
    </div>
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

我使用ui-semantic popup 代码背后

 protected void Button4_Click(object sender, EventArgs e)
    {
        try
        {
            acceptance ac = new acceptance();
            ac.user_id = Convert.ToInt32(usid.Value.ToString());
            ac.work_id = mywork.id;
            ac.detail = details.Value.ToString();
            ac.dead_time = Convert.ToDateTime(date.Value.ToString());
            DataClasses1DataContext db = new DataClasses1DataContext();
            var hj = from i in db.acceptances where i.user_id == ac.user_id && i.work_id == ac.work_id select i;
            if (hj.Count() > 0)
            {
                Exception c = new Exception("this user alredy accepted");
                throw c;
            }
            var maxValue = db.acceptances.Max(x => x.id);
            ac.id = maxValue + 1;
            db.acceptances.InsertOnSubmit(ac);
            db.SubmitChanges();
        }
        catch (Exception ex)
        {
            HtmlGenericControl er = (HtmlGenericControl)this.Master.FindControl("error");
            HtmlGenericControl al = (HtmlGenericControl)this.Master.FindControl("alert");
            al.Visible = true;
            er.Visible = true;
            er.InnerText = ex.Message;
        }
    }

0 个答案:

没有答案