現在、私は完全にIE、クロム、サファリのために、私はGridviewの中に焦点を当てているテキストボックスのID名を取得するための機能があります。代わりにevent.srcElement.id
function onTextFocus() {
alert(event.srcElement.id);
}
機能は、GridViewのためのRowDataBound中に呼び出されます。
protected void ItemGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((TextBox)e.Row.FindControl("txtQuantity")).Attributes.Add("onfocus", "onTextFocus();");
}
}
それはsrcElementを認識しないとして、それは、Firefoxのために動作しませんが。だから私はすべてのブラウザで動作する代替を探しています。 Googleを精練した後、私はこれらの選択肢を考え出しましたが、私は未定義のエラーまたはReferenceErrorを取得します。なぜどんなアイデア?
function onTextFocus() {
alert(this.id);
alert(event.currentTarget.id);
alert(event.target.id);
alert(event.currentTarget);
alert(event.target);
alert($(this).attr('id'));
alert($(obj).attr("id"));
alert($(this).id);
alert($(this).get(0).id);
alert($(this).prop("id"));
}
ショーどのように、あなたが方法 – Satpal
を使用しているが問題は、することができます解決されます。また、いくつかのより多くの支援が必要ですか? –