GirdView ın bulunduğu aspx sayfamızın source kısmına aşağıdaki JavaScript kodunu ekliyoruz
function DeleteText(ctrl)
{
document.getElementById(ctrl).innerText="";
}
daha sonra GridView ın RowDataBound eventine
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)
{
TextBox txt = new TextBox();
txt = (TextBox)e.Row.FindControl("TextBox1");
txt.Attributes.Add("onfocus", "DeleteText('"+txt.ClientID+"')");
}
}
kodunu ekledikten sonra gridview da herhangibir satırdaki TextBox a tıkladığımızda içerisinde bulunan değer kaybolmuş olacak.
veya
Çok kısa bir çözüm daha
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" onfocus="if(this.value=='hede hödö') {this.value=''};" ></asp:TextBox>
Bu yazıyı ilk değerlendiren siz olun
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5