2017-08-15 9 views
0

ASP ButtonのClickイベントでjavascript関数を呼び出そうとしていますが、その関数からModal Popを呼び出すhtmlボタンをクリックしようとしています。ModalPopupを表示するにはModalPopupextenderを使わずにASPボタンをクリックしてください

ステータス: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'); 


    }); 
ヘッド部で

 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を提供ちょうど*リフレッシュする - 更新パネル内のモーダルではないですか?また、モーダル部門のIDを確認しましたか? –

+0

をリフレッシュ....ページ機能しない – Nisarg

+0

Modalは更新パネル内にありません..... Modal本体内にあるにもかかわらず、更新パネルがあります –

関連する問題