Attributes.Add to the button.
use this code..
Button1.Attributes.Add("onclick", "return callingfn()");
Consider javascript as follows
<script defer="defer" type="text/javascript" language="javascript">
function callingfn()
{
var objTextBox = document.getElementById('TextBox2');
objTextBox.value = "123";
return objTextBox.value();
}
</script>
whole code like this..
<html >
<head runat="server">
<title> Untitled Page</title>
<script defer="defer" type="text/javascript" language="javascript">
function callingfn()
{
var objTextBox = document.getElementById('TextBox2');
objTextBox.value = "123"
return objTextBox.value();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:TextBox ID="TextBox2" runat="server" > </asp:TextBox> </td>
</tr>
<tr>
<td align ="center"> <asp:Button ID="Button1" runat="server" Text="Button" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
No comments:
Post a Comment