2017-01-20 4 views
0

私は現在、ウェブサイトを開発中です。私は、外部のjsのコードは私がやりたいことのGridViewに選択された行のIDを取得しているメッセージボックスにIDを表示する方法は?

function DeleteConfirm(rfqcodeLB) { 
    var confirm_value = document.createElement("INPUT"); 
    confirm_value.type = "hidden"; 
    confirm_value.name = "confirm_value"; 
    if (confirm("Are you sure you want to delete" + rfqcodeLB +" ?")) { 
     confirm_value.value = "Yes"; 
    } else { 
     confirm_value.value = "No"; 
    } 
    document.forms[0].appendChild(confirm_value); 
} 

ファイルを持っています。私がしたのは、選択したコードをrfqcodeLBという文字列に転送することでした。そして、属性をボタンに置​​きます。しかしそれはヌルを示します。

誰かお手伝いできますか?ありがとう。

<asp:ImageButton ImageUrl="../Pictures/Icons/deleteblack.png" runat="server" OnClick="Unnamed_Click" ID="deleteBT" OnClientClick="return DeleteConfirm(ContentPlaceHolder1_rfqcodeLB);"/> 

答えて

0

this.id.を使用し、代わりContentPlaceHolder1_rfqcodeLBの、関数のパラメータとしてIDを渡します

+0

をしたい場合にのみ、あなたのImageButtonのIDではなく、選択した行のIDを取得します。 – VDWWD

0

RowIndexをJavaScript機能に送信する必要があります。 this.idではなく、ImageButtonのIDのみを取得します。

<asp:ImageButton OnClientClick='<%# "return DeleteConfirm(" + Container.DataItemIndex + ");" %>' ImageUrl="../Pictures/Icons/deleteblack.png" runat="server" OnClick="Unnamed_Click" ID="deleteBT"/> 

それとも、データベース値

OnClientClick='<%# "return DeleteConfirm(&#39;" + Eval("yourID") + "&#39;);" %>' 
関連する問題