How to access all property of List box using JavaScript function.
Step 1 : First create your website in asp.net and create one
.aspx page .
Step2: Open .aspx page and drag and drop ListBox contol
oncopy="return txt1_oncopy()" onpaste="return txt1_onpaste()" oncut="return txt1_oncut()"></asp:TextBox>
Step 3 : All all script at page header portion to handle text box event.
function txt1_onChange() {
var txt = document.getElementById("<%= txt1.ClientID %>");
alert("onFocus value is = " + txt.value);
return false;
}
function txt1_oncopy() {
//do your transcation
// return true for allow copy
return false;
}
function txt1_onpaste() {
//do your transcation
// return true for allow paste
return false;
}
function txt1_oncut() {
//do your transcation
// return true for allow cut
return false;
}
</script>
Step 5 : Just run your code and check is your code is running perfectly and access all event of textbox control.
Inherits="JavaTextboxControl" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>List Box Example</title>
<script type="text/javascript">
function txt1_onChange() {
var txt = document.getElementById("<%= txt1.ClientID %>");
alert("onFocus value is = " + txt.value);
return false;
}
function txt1_oncopy() {
//do your transcation
// return true for allow copy
return false;
}
function txt1_onpaste() {
//do your transcation
// return true for allow paste
return false;
}
function txt1_oncut() {
//do your transcation
// return true for allow cut
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<br />
<asp:TextBox ID="txt1" runat="server" onChange="txt1_onChange()" oncopy="return txt1_oncopy()"
onpaste="return txt1_onpaste()" oncut="return txt1_oncut()"></asp:TextBox>
<br />
</body>
</html>
No comments:
Post a Comment
Thank you for your interest .