Calling a JavaScript funtion from ASP.NET
Requirement :
Calling a javascript function which return strings and binding it to textbox of asp.net page
For e.g . You have a javascript function say
MyJavaScript() whichs return string, on click of button you need to call javascript function and
bind the returned value to textbox.
Code Snippet
function MyJavaScript()
{
return 'Text from JavaScript';
}
asp:TextBox ID="mytxtBox" runat="server"
asp:btn ID="myButton" runat="server"
Text="Click to Get Value"
OnClientClick ="document।getElementById('mytxtBox').value= MyJavaScript()"
/asp:btn
Output
Requirement :
Calling a javascript function which return strings and binding it to textbox of asp.net page
For e.g . You have a javascript function say
MyJavaScript() whichs return string, on click of button you need to call javascript function and
bind the returned value to textbox.
Code Snippet
function MyJavaScript()
{
return 'Text from JavaScript';
}
asp:TextBox ID="mytxtBox" runat="server"
asp:btn ID="myButton" runat="server"
Text="Click to Get Value"
OnClientClick ="document।getElementById('mytxtBox').value= MyJavaScript()"
/asp:btn
Output
No comments:
Post a Comment