Adding JScript Event To Aspx control
Hey Guys ini hal menarik yang aku dapat kemarin ketika ngedevelop web App C#,
Bagaimana cara menambahkan "Jscript event to Aspx control" , Here’s the tip ..
First ..
Tambahkan baris kode berikut ..
<server code>
TextBox1.Attributes.Add("onblur", "validateText(id);");
</server code>
Kamu bisa menambahkan pada pageload atau event button component aspx
Secondly ..
Tambahkan beberapa baris kode pada .aspx kamu..
<client code>
function validateText(Item)
{
chek=document.getElementById(Item).value;
if (chek=="cacau")
{
alert(" It’s Work ! ");
}
}
</client code>
Dan coba run dan buktikan … 
– code diatas menghasilkan
<view Html Source>
<asp:TextBox ID="TextBox1" runat="server" Enabled="true" Visible="True" onblur="validateText(ID)">
</asp:TextBox>
</view Html Source>
– Hal yang menarik , apabila kita langsung menggunakan tag seperti pada <view html source> maka kemungkinan akan di tolak dan dianggap tidak valid oleh compiler.. (That what’s happen to me , it’s just me or ??) , Selamat Mencoba
