2017-08-15 85 views
0

我想调用ASP按钮的Click事件上的JavaScript函数,并从该功能我试图点击HTML按钮,将调用模态流行。显示引导ModalPopup上点击ASP按钮,而不使用Modalpopupextender

状态:我可以提交html按钮的单击事件并在其中运行警报箱,但不能运行ModalPopup。我也可以通过直接点击HTML代码来打开ModalPopup。

代码: //代码

protected void Button1_Click(object sender, EventArgs e) 
{ 
    Button btn = (Button)sender; 
    RepeaterItem ri = (RepeaterItem)btn.Parent; 
    Label id = (Label)ri.FindControl("payid"); 
    Add_Account_Head_1.headid_property = id.Text; 

    update1.Update(); 

    string script = "showpop();"; 
    ScriptManager.RegisterStartupScript(this, GetType(), 
          "ServerControlScript", script, true); 

} 

在主体部分

$("#btn1").click(function() { 
     //  alert('This has been clicked'); 
     $("#myModal").modal('show'); 


    }); 

head部分

 function showpop() { 

      var button = document.getElementById('btn1'); 
      button.click(); 
     }; 
+0

提供的模态 –

回答

0

你可以做这样的事情,直接从调用modal.show服务器端。但请确保#myModal是正确的选择器。您可以从开发工具验证ID。

protected void Button1_Click(object sender, EventArgs e) 
{ 
    Button btn = (Button)sender; 
    RepeaterItem ri = (RepeaterItem)btn.Parent; 
    Label id = (Label)ri.FindControl("payid"); 
    Add_Account_Head_1.headid_property = id.Text; 

    update1.Update(); 

    string script = "showpop();"; 
    ScriptManager.RegisterStartupScript(this, GetType(), 
          "ServerControlScript", "$('#myModal').modal('show');", true); 

} 
+0

一些HTML没有工作....页面只是刷新 –

+0

*页面只是刷新* - 不是更新面板内的模式?你是否也验证了模态div的ID? – Nisarg

+0

Modal不在任何更新面板内.....更新面板虽然在Modal Body内 –